Animation Adventures

Read Time:3 Minute, 9 Second

Nothing ever works out of the box. True Story. Here’s how to make Mixamo animations work when you import them into Unity.

Mixamo Animations… They work, just not out of the box.

TL:DW here’s what you need to do:

  1. Download and import the FBX animations you want to work with.
  2. Highlight the lot of them.
  3. In the inspector, click Rig and then set the Animation Type to Humanoid.
Change the Animation Type to Humanoid

That will be enough to make the animations work. In my opinion, they all need to be renamed as well and for animations that should loop, you need to check that box as well.

Rename the animation and check loop time for movement and idle animations.

Once those animations are in Unity, we still have some work to do with Root Motion vs the Nav Mesh Agent. These guys do not love each other.

This video took like 5 cuts to get done. Sheesh.

Animators and Nav Mesh Agents do not play nicely. Fortunately, it’s not too hard to get them to work together. You need to choose which is going to follow the other. Your artist is going to want you to choose Root Motion. Probably. I don’t know any artists who do animation personally, but you could probably send one of them on the Asset Store an email and find out.

Ok, anyway, here’s what you need to do:

  1. Make sure you’ve got your Nav Mesh Agent and your Animator on the same Game Object. I had a weird bug earlier today that was solved by making this a rule.
  2. Make sure your animator is using your model’s Avatar and the Animation Controller you made for it.
  3. Check the Root Motion box.

The next part is handled by the Zombie Animator script which links up to the Follow Target Script.

In order to keep the Follow Target decoupled from the animator, I created two events that the designer can use to communicate with whatever other components might be interested.

In this case, we want to trigger the Walk animation when we start following a target, and the Idle animation when we stop.

Here’s the code behind the Zombie Animator script:

The red box highlights the line of code that stops the Nav Mesh Agent from moving our character, which prevents the ice skating effect that I showed off in the video. Under it you see that we do want the agent to continue to handle rotating the character.

The blue box highlights a line of code that is important because the Nav Mesh Agent does still need to move. Since we stopped it from moving on its own, we get to do it ourselves.


There’s one last detail. When we stop a Root Motion animation, it will often create a dissonance that causes the Nav Mesh Agent to rotate a bit. This is caused by the Stopping Distance setting of the Nav Mesh Agent which defaults to 0.

Set the Stopping Distance to a value like 0.5 and what this means is that the Agent will be content to call a journey finished as soon as it is within 0.5 units of its target destination.

The value you need to set for the Stopping Distance will vary with your Root Motion. The faster it is, the bigger the value you may need. Now, there is another solution which involves stopping the Nav Mesh Agent.

The Is Stopped property of the Nav Mesh Agent is a Big Red Button. Setting it true stops all function of the Agent cold. No further calls to the Agent will work (allegedly, I haven’t tested this out) until Is Stopped is set false again.

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleppy
Sleppy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published. Required fields are marked *