Nerd For Tech
Published in

Nerd For Tech

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.

RollBehaviour is attached to the Roll state.

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

And with that we have a decently working roll!

--

--

--

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/.

Recommended from Medium

AVRO vs Parquet — what to use?

our game is cryptographic

How to test push notifications in Xcode 11.4 simulator

Book Notes: Lean Software Development — Mary Poppendieck and Tom Poppendieck

We Are Not Serious Enough About Software Development

Shortform: What Exactly are Systems?

Atlassian Team Tour Recap

Implementing Custom Dapr State

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
Esteban Ibarra

Esteban Ibarra

cartoonist, game artist, and wanabe gamedev.

More from Medium

2.5D Phase1 Framework: Collectible

Magnetism in Unity Made Easy!

Using Unity’s ProBuilder To Model A Sci-Fi Container

Adding a ram attack to our boss