Player Setup Part 6

Simon Leen
3 min readSep 21, 2021

--

Objective: Jump Animation

As you can see above, when the Player jumps he stays in idle stance. Let’s get it jumping with a better animation.

We follow the same process setting up a new animation clip as we did with the idle and run animations and transitions.

We use a bool parameter for the jump in the Animator Controller and use the speed to decide whether or not to go from jump to idle or run after jumping.

Unlike the idle and run animations we need to turn loop anaimtion off for the jump animation.

Next open the PlayerAnimation script and create a public method called Jump that takes in a bool parameter. This will be passed from the Player script. We then set the aniamtor SetBool on the Jump parameter to the bool value passed in which can turn on and off the jump animation.

We then call the Jump method inside the Player script. We call Jump with a bool value of true inside the space key input logic and call it again in the IsGrounded method, passing a false bool value.

If we try at this point, we will get the jump animation but the Jump animation never goes back to false as we only check if the Player IsGrounded when the space key is pressed. This gives the result shown below.

To fix this, create a private bool called isGrounded and set it to the called IsGrounded method call in the Movement method.

--

--

No responses yet