Root Motion vs Nav Mesh Agents
I did a deepish dive into this topic on Zombie Runner and forgot about it when I wrote the patrol code for Bossk. He was hanging up on the corners and I suspect it was because the agent was moving faster than he was or something like that.
My solution in Zombie Runner and here as well is to shut down the Root Motion and allow the Nav Mesh Agent to drive Bossk about but then to set the speed of the Agent using the Root Motion animation. It looks like this:
This component deals with starting and stopping the Nav Mesh Agent and Animator components whenever we want the character AI to move to some part of the level.
This script handles the Patrol action of the Bossk character in the video. It requires a game object set up with children that have colliders set up as triggers. When the trigger is flipped it checks to see if the collider belongs to the current waypoint and if it does then we move on to the next waypoint.
Enemy Animator Controller
Part of this code was discussed earlier, but I wanted to show the whole thing here because it shows my strategy for dealing with animator properties by wrapping the string literals with constants and using properties to encapsulate the animator Get and Set calls.
You can go a level deeper by using the String To Hash method of the Animator object. It is a static method that retrieves the hash ID of whatever property has the given name. Then you supply the hash ID instead of the string to the Get and Set methods. Since the search will be done on an integer instead of a string, the result is a faster seek for the property.