Adding a running animation in Unity

Jaime
3 min readNov 13, 2021

--

After taking care of the idle animation, it’s time to configure how to animate the players action of running. Since we are using a character controller, we will search for a run animation in Mixamo and tick In Place to let the Physics controller dictate this.

When you download an animation make sure of the following:

  1. Format: FBX for Unity
  2. Skin: With Skin

You can optimize FPS and Keyframe Reduction based on your requirements.

Then I added the Running animation in my Animations folder. I also set the Rig to Humanoid and clicked Apply.

I also ticked Loop Time and renamed the animation to Running.

Next I dragged the running animation to the Animator and renamed it again to Running.

I added transitions to and from Idle.

I added parameter Speed to add conditions to the transition.

I set unticked Has Exit Time and set Transition Duration(s) to 0 so that the transition is immediate. I set condition that if Speed is greater than 0.1 then it should transition from Idle to Running.

On the other hand, going back to Idle will have the same settings except Speed should be less than 0.1.

You need to pass the parameter of Speed from the controller. I set the Animator as [SerializeField] so that it’s easy to provide a reference to this object. Also, I had to get the absolute value of the input so that both going left and right is covered by the transition.

Then I dragged the Animator reference to the Player.

Also, to make sure that the Player does not skew when moving, we need to untick Apply Root Model from the Animator Controller.

Now, the Player can transition from running to being idle and vice versa.

Although, you can see with Idle that it’s sliding its feet. You need to set Root Transform Rotation->Bake Into Pose for the Idle animation and Apply to remove the sliding feet.

--

--

Jaime
Jaime

No responses yet