Creating a Roll Player Action in Unity

Objective: create a functionality to make the player roll when the user presses the left-shift key.

First we need the animation, for this project I downloaded all the animations from mixamo.com. Just go to the search bar and find the animation you are looking for. In this case I searched for “Roll”.

Now in the animation controller I added the new animation and created transitions from idle and run state. I created a trigger parameter called “Roll” to trigger the animation from the script.

In the player controller script I declared a transform variable that is used to store the final position when the roll animation finished (this variable is assigned in the inspector). Within the calculate movement function I check for the left-shift key to trigger the animation and also create 2 functions. Roll() triggers the roll animation and disables the player controller and RollCompleted() sets the new position and enables the player controller component.

Next for the roll animation I created a new behavior script. In the script I use the OnStateExit() to call the RollCompleted() function when the animation finishes.

And that’s it!!! We have a roll animation for the player.

--

--

--

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Types Of Arbitration To Manage User Permissions In AssetSonar

Types of arbitration

Introducing the InfluxDB Template UI: Monitoring Made Simple

Choose The Long Live Tech Stack

Taming a Network Filter

Should I opt for a Customisable or Configurable Software Platform?

AWS/Terraform Workshop #2: EC2 Networking, Autoscaling Groups, CloudWatch

test out another

IoT Cisco Virtualized Packet Core (VPC)

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
Rusben Guzman

Rusben Guzman

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.

More from Medium

Creating A Ledge Grab in Unity — Part 3: Snap player in the ledge position.

How to animate sprites in Unity

Guide to Making a Beautiful Game: Altering Texture Maps

How to Install Post Processing in Unity 2019.3 and Above!