Journal 88–2.5D Platformer Challenge, Add a Player Roll Animation

Objective: Add a player animation for rolling along the platform level

In this article, we will add a rolling animation while running.

We can start with searching for an animation at Mixamo.

Then we can drag this animation into Unity and fix the rig by setting to “Humanoid” and duplicating the animation to make it editable.

After importing we can expand the animator tree and add transitions to running.

Next we can update the transitions with a roll trigger. Also we need to update the roll behavior after completion with a short script, similar to the climbing ladder script and climb up behavior after grabbing a ledge. For the transition from running to rolling, we can turn off exit time and make a short transition at about 0.1, and for the transition from rolling back to running, we can keep the exit time selected to finish the animation.

Now let’s update the Player script, with a left shift action to initiate the roll while disabling the character controller briefly, then we can add a roll complete function to set the position at an empty game object to the left and right of the character.

We can set the left and right roll positions.

Finally, we can see the roll animation in action.

Thank you for your time!

--

--

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