Today we will add jump animation to our character.
Go to Mixamo and find an jump animation you like. My character is a ninja, so I am using ninja jump animation.
Before you click on download button, make sure that In Place option is checked. We want to move our character using Character Controller, not animation.
Import the file to you project. Change the Animation type to Humanoid. Click on the animation, and press Control + D to duplicate it.
Set Loop Time on the animation to true.
Go to Animation controller view and add Jump animation. Make a transition from Run to Jump, Jump to Run, and Jump to Idle. I will cover transition from Idle to Jump in future article.
Add a new bool parameter called Jumping.
In the transitions, set conditions. When we transition from jumping animation we need to check if Jumping is set to false, and also what is the speed of our Player.
Run -> Jump
Jump -> Run
Jump -> Idle
Last thing is a script. Open the Player script and add a new variable called _jumping.
Go to Update() method. When we jump, we will set _jumping to true, and pass the parameter to the Animator Controller using _anim.SetBool(). After jumping, we are checking if _jumping is true. If it is, we will change it back to false, and again, pass the parameter to the Animator Controller.