How to add rolling to the platformer controls in Unity
Jun 24, 2021
Let’s go over how to add rolling to the platformer project.
I am continuing to build on the Player script from this article. The roll animation is from mixamo.com.
Open the Player script. Add a coroutine called Roll. The coroutine will shrink the collider on the Character Controller and also move it to a lower position. Yield for one second and then reset the collider’s size and position:
Inside the PlayerMovement function check for the input from the Shift key and if the player is on the ground, call the coroutine and set the animation trigger:
Lastly, add the animation to the animator controller and set transitions:
Good luck!