Platformer: Player Animation Part 3

Intro

In this article, I will cover how to add a jumping animation and how to translation between running, jumping and idle animations.

Animation Setup

When we have downloaded animations from Mixamo before there is an option to have the animation be In Place. This means the animation doesn’t control the movement of the character, but this animation doesn’t have this option. We can still download it and change some settings in Unity, so we can control the animation and not have the animation control us.

In the animation setting, we can set Bake Into Pose true for the Root Transform Rotation and Position. This prevents the Root animations from controlling the movement in those respective areas.

Running to Jumping Animator

We are going to add a transition from the Run animation to the Jump animation. We are going to use a Trigger parameter, which allows us to call the parameter in the script and it will simply make the transition. We want to set Exit Time false, since we want the jump animation to instantly play.

We call the trigger in the code by accessing the animator via the _anim handler, and SetTrigger and pass in the name of the Trigger you want to activate.

Jumping to Running Animator

In the transition from Jumping back to running, we will use the speed float parameter. We will want to set the Exit Time true, since we want the jumping animation to finish before transition back to the running. For the condition, we want the Speed to be greater than 0.1, meaning we are pressing the arrow keys.

We cover this in the previous article, but the Speed float is set to the horizontal input which determined by the left and right arrow keys being pressed.

Jumping to Idle Animation

For the transition from Jumping to Idle, we again will use the Speed parameter but this time the condition will be Speed less than 0.1, meaning the arrow keys are not the being pressed. Again, Exit Time is true since we want to finish the jump animation before going to the Idle.

Conclusion

This is a start to the animation, but there are still some issues with it, like the running animation playing a bit before transitioning into Idle and when the player jumps without moving than moves, it triggers the jump animation.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store