/*The delegate currentMovement is called every frame, allowing the player to move differently depending on which method currentMovement currently refers to*/ //ChangeMovement assigns a new method to currentMovement public void ChangeMovement(string movementType) { dashVelocity = null; dodgeVelocity = null; if (combat.Dead) { currentMovement = NoMovement; return; } switch (movementType) { case "None": currentMovement = NoMovement; break; case "Previous": currentMovement = previousMovement; ChangeMovement(currentMovement == DefaultMovement ? "Default" : "LockOn"); break; case "Default": currentMovementType = "Default"; currentMovement = DefaultMovement; previousMovement = currentMovement; anim.SetLayerWeight(2, 0); moveSpeed = 10f; break; case "LockOn": currentMovementType = "LockOn"; currentMovement = LockOnMovement; previousMovement = currentMovement; anim.SetLayerWeight(2, 1); moveSpeed = 5f; break; case "Dash": if (currentMovement == LockOnMovement || currentMovement == DefaultMovement) { print("dash movement"); anim.SetTrigger("Dash"); currentMovementType = "Dash"; previousMovement = currentMovement; currentMovement = DashMovement; } break; case "Dodge": if (currentMovement == LockOnMovement || currentMovement == DefaultMovement) { anim.SetTrigger("Dodge"); currentMovementType = "Dodge"; previousMovement = currentMovement; currentMovement = DodgeMovement; } break; case "StrafeDodge": if (currentMovement == LockOnMovement) { anim.SetTrigger("Dodge"); currentMovementType = "StrafeDodge"; previousMovement = currentMovement; currentMovement = StrafeDodgeMovement; } break; } }