I'm trying to make my character dodge in a straight line in midair.
With my code now, they dodge in the direction they're heading, diagonality included.
[link text]
[1]: https://www.youtube.com/watch?v=qsDtB-vZToI
I'm using a State Machine system. Here's my Tick method as of now.
public override void Tick(float deltaTime)
{
Vector3 movement = new Vector3();
movement += stateMachine.transform.forward * stateMachine.DodgeLength / stateMachine.DodgeDuration;
Move(movement, deltaTime);
remainingDodgeTime -= deltaTime;
if(remainingDodgeTime <= 0f)
{
stateMachine.SwitchState(new PlayerFallingState(stateMachine));
}
}
I've been told the
movement += stateMachine.transform.forward * stateMachine.DodgeLength / stateMachine.DodgeDuration;
line is what's causing the "charge" and to start my AirDodge with the direction I want to charge (in this case, straight 0 degree forward to maintain elevation).
Problem is: I'm stumped on how to accomplish this. Could anyone help me please?
If possible, I'd also like to set up a range, like the player can only launch between 0 and 45 degrees (this would avoid dodging downward or too high upward).
↧