Creating a Player Roll Animation

Explaining how I implemented a player roll animation in my 2.5D game.

Gabe Gomez
2 min readJul 30, 2021

Objective: Implement a player roll animation in my 2.5D game project.

The Animations

To complete this task, the first thing I did was go to mixamo.com and grabbed a nice roll animation. I specifically grabbed the animation I show below.

I imported what I needed into my project with my animation and then hooked it up to my player’s animator controller. In my case, I only want the player to be able to roll if they are already running. The screenshot below shows how I implemented the logic for the animation given that.

Highlighted in blue are the connections dealing with the new “Forward Roll” animation. I also added a trigger in my animator’s parameters named “roll” so I can code in the functionality of when I want my player to do the roll animation.

The Functionality

With the animations set up, I then went into my player script to code things up. I started by adding this piece of code to a function I have named CalculateMovement(), which is called in every update loop.

Notice I have a coroutine being called in this method. The code for that coroutine is shown here.

I use this coroutine to prevent the player from changing the direction of their roll once already initiated. With all this, I got the following result:

That’s all for today! Thank you for reading! There will be more to come soon.

--

--