How do you make sure that a NavMeshAgent undergoes the right transition in order to not slide - or to get stuck in the timing of an odd state?
I assume your animation uses root motion to move the object? In that case you can implement your own “root motion” through script.
In a script that is on the same gameObject as your animator, do the following:
void OnAnimatorMove()
{
// You'd have to set this value yourself, lots of ways to do that with the animator.
bool isMoving = true;
if (isMoving)
{
agent.velocity = CharacterAnimator.deltaPosition / Time.deltaTime;
agent.speed = CharacterAnimator.deltaPosition.magnitude / Time.deltaTime;
}
else
{
agent.velocity = Vector3.zero;
agent.speed = 0.00001f; // Setting it to 0 can cause agent to do weird stuff
}
}
You’ll notice in the inspector that the animator component now notes the “Apply Root Motion” variables as “Handled By Script”.