- Home /
How do i reset the destination of my navmeshagent?
hi everybody
I'm searching for a solution to stop my object with a navmeshagent. It should return to the state it had before asigning a the variable navmeshagent.destination.
The reason for that is that i can carry the object around and its point in the level changes, and i don't want to rewrite the .destination in every update with this.transform.position.
Answer by Hoorza · Dec 04, 2018 at 10:29 PM
I have used both:
NavMeshAgent.isStopped = true;
NavMeshAgent.ResetPath();
after that, I was able to give it a new destination no problem.
Answer by chrysillo · Oct 25, 2017 at 01:00 PM
Set its updatePosition to false. https://docs.unity3d.com/540/Documentation/ScriptReference/NavMeshAgent-updatePosition.html
Setting updatePosition to false will not clear agents destination, it will not even stop it from being calculated, it merely stops the path from being applied to the transform. I think this one would be more suitable: https://docs.unity3d.com/540/Documentation/ScriptReference/Nav$$anonymous$$eshAgent.ResetPath.html
Nav$$anonymous$$eshAgent.ResetPath() will clear its path and not look for new one until SetDestination() is called.