How to do it...

To use root motion for moving and steering a character with Nav Mesh Agent component, follow these steps:

  1. Import the character with the Idle, WalkLeft, WalkForward, and WalkRight animations and set it up the same way as in the Using root motion to steer a character recipe, but don't write the RootMotionSteering.cs script as we will create a new one.
  2. Add the Nav Mesh Agent component to the character. Make sure it also has the Capsule Collider component and the Rigidbody component with frozen rotation in every axis. Also make sure that the Animator component's Apply Root Motion option is set to true and Update Mode set to Animate Physics (the same way as in the Using root motion to steer a character recipe).
  3. Bake the NavMesh ...

Get Unity 5.x Animation Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.