0
\$\begingroup\$

If I determined the NavMeshAgent is as close to its destination as it's ever going to get, what do I do with it? Do I set the destination to the agent's current position? Do I set isStopped to true? Because it'll still be trying to get to that destination and I don't want it to keep trying.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Did you try ResetPath? \$\endgroup\$
    – DMGregory
    Jul 7, 2022 at 13:23

1 Answer 1

1
\$\begingroup\$

If this is a general problem whenever your agent tries to reach any destination, you should use the stoppingDistance property of NavMeshAgent:

//Stop when we're 1 meter from our destination
navMeshAgent.stoppingDistance = 1;

If it's a situational issue, where you use your own code to determine that the agent can't get closer to a specific destination, you can use navMeshAgent.isStopped = true (don't forget to un-stop it later when it's given a new destination!) or navMeshAgent.ResetPath().

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .