In Unity, I'm trying to give velocity to my player while jumping, AKA keep going forward if you jump mid-motion. Here is my code so far:
if (VerVelocity != 0 || HorVelocity != 0) {
if (Anim.GetCurrentAnimatorStateInfo(0).IsName("jump") || Anim.GetCurrentAnimatorStateInfo(0).IsName("fall")) {
transform.Translate(Vector3.forward * VerVelocity * JumpSpeedMultiplier * Time.deltaTime);
transform.Translate(Vector3.right * HorVelocity * JumpSpeedMultiplier * Time.deltaTime);
}
}
HorVelocity and VerVelocity are top down, meaning Hor is for left and right and Ver is for forward and backwards. The problem I'm having is these events can happen in any order, meaning you can change direction mid-air. How can I make it check that you were running before you jumped and not after? Thanks for any help you can provide!
Aucun commentaire:
Enregistrer un commentaire