It’s time to learn how to make our character roll!
We need an animation for this. We will find it on Mixamo. Download it and upload it to Unity. Change the animation type to Humanoid.
Add the animation to Animator. Add “Roll” Trigger parameter and set up transitions between Idle, Run and Roll. Make sure that transition to the roll animation doesn't have exit time.
We want to roll when pressing on the left shift key. We need to check if the key was pressed in the Update method. We will set trigger in the Animator and disable CharacterController, like we did with climbing animation.
We need to know when the roll animation is finished. Go to Animator and click on the Roll animation. Add a new script called RollBehaiour.
Add this method to RollBehaviour to call Roll method when the animation is finished.
Last thing we need to do is change the position of the Player to the position of the model after rolling and enable CharacterController.