Transition From Idle Animation to Running Animation in Unity!

Objective: Implement a running animation and creating parameters to control the transitions.

In the last tutorial we discussed how to download and implement animations from Mixamo. In this tutorial we are going to do this again with a running animation. We are going to control transitions from idle to running with code and parameters.

First off, we need to head to Mixamo. Search for a running animation and choose one that you like. Select download and make sure it is set to FBX for unity. Follow the steps of the previous tutorial until you drop the animation into the animator view.

With the clip in the animator view we can now create a transition from the idle animation and to the idle animation.

We want to control this transition using parameters. Press the plus button to the left of the view and we need a float parameter.

On the transition to the running animation add the condition, Speed is greater the 0.1 and has exit time turned off. On the transition to back to the idle add the condition Speed is less than 0.1 and has exit time is turned off.

Open the player class script and we need a reference to the animator that is currently on the child object.

With a reference to the animator you need to think of where do you want to manipulate the animator. Since we are dealing with a speed float to transition to the running animation you should place this code where you determine the direction of the player. Also, we need to use the absolute values of our numbers. This means that negative one, when you player is moving to the left, the value is positive 1.

Our current setup using “GetAxis” means it slowly increments to one. For a faster response we need to switch to “GeAxisRaw”

Now you should have a quick response from your input to the player animation. To give yourself a smoother transition or less of one, select the transition line, select setting in the inspector and increase or decrease the transition duration.

In the next tutorial we will be covering how to create a ledge grab in Unity! Don’t be afraid to experiment with your animations and I’ll see you in then ext tutorial!