Objective: Complete the Jump animation using code to control the transition from idle to jump and back to idle.
In the last tutorial we created a jump animation clip and made transition from our Idle animation to the jump animation and back. We added a bool parameter condition that controls when we make that transition. In this tutorial we are going to use code to control that bool.
Open our players animation script. We already have a handle for the animator. We need to create a new method “Move” with a bool parameter.
We want to set the animation bool parameter “Jump” to the method parameter.
Now we need to navigate to the player script and decide when we want to call this method. When the reset jump is false the method “IsGrounded” returns true. When that happens we want to set the animation bool to false.
Now when do we want to set the animation bool to true? When the player hits space we want to call the jumping method with a true parameter.
This will now turn the jumping bool to true when the player hits space and is grounded and will return to false when the player is grounded.
Don’t be afraid to experiment with your animations and I’ll see you in the next tutorial!