How to move NavMesh Agent by animation?

What’s the best way to create a simple moving navmesh agent with animation? (e.g. a human enemy running to player)

I have run animation that moves the enemy (which I activate by calling Run() function that sets some properties on Animator) but I am not sure how to combine it with navmesh.
alt text
In one tutorial I saw Standard Assets ThirdPersonController’s .Move(…) used for that, but I am not sure if I should use it for that purpose, as I understand it was intended only for player characters?

Or should I use animation that runs in place?

The Unity manual has a page on this:

Good day.

You have to use nav mesh agents for moving objects arround the scene, and animations to other things, but not to translate the object itself.

If a gameobject have a navmeshagent component and an animator, it will be able to move “automatic” by navmesh conponent (changing it transform.position and transform.rotation), so animation must do anything except move the transform.position/rotation of the object. What can do the animation is change the localposition and localrotation of childs, but not the gameobject itself.


If helped, accept the answer and close the question!

Bye!!

No, it’s not automatic at all. Check this manual page that gets you started. This older manual page also may be helpful with using NavMeshAgent with other components.