Daily progress — They see me rollin’

This challenge was a lot of fun to implement in spite of some issues that really opened up the way to various methods of implementation.
Mixamo had many roll styles but the first one seemed to be what I needed.

After downloading it, making sure fbx-unity was selected, I imported it and made sure Humanoid was the rigging style. I then duplicated the animation and moved it into the players animation tree.

I used these settings:
Idle to roll:
No exit time, Fixed duration, transition duration .1, conditions: Roll triggered.
Roll to Idle:
Has exit time, no fixed duration, transition duration 0, conditions: Speed < .1
Run to Roll:
No exit time, no fixed duration, transition duration .2, conditions:Roll triggered
Roll to Run:
has exit time, fixed duration .25, condition:Speed > 0.
In the player code I made a function for the roll check just to have it isolated:

When the player hits left-shift, the controller is turned off temporarily so the player can’t change directions during the roll. I could have left it on, but I wanted a committed roll. the animation is then triggered and a coroutine is started to move the player left or right, depending on on where they’re facing.

distance is the amount of space the player covers while rolling. Then there’s a check to see if the player is facing right or left, depending on where, it will be 9 or -9.
A new variable called newPos is made to add the distance to our current transform position. if the player is facing right, then the player is moved towards the newPos position using Vector3.MoveTowards until he reaches it. Same with the left.
Finally, the animation has a behaviour script that’s created in the Animator attached to it that calls the “EndRoll” Function.


To finish the roll, I just turn on the character controller:

And with that we have a decently working roll!