I know this has been answered before, but wonder if there is a more up-to-date answer.
For my agent, I am using Unity’s Character Controller, along with Seeker and AIPath. And I am using a simple Grid Graph.
I start the navigation by simply setting agent.destination = destination. Whenever the agent gets within a certain distance from the destination, I would like to totally cancel this navigation, and stop the agent completely (as it has “run out of fuel”). I know there are various ways to do this, but what is the best/recommended way?
It makes the AI component clear its path. The Seeker is the one drawing the green line, and it will always draw the last path request regardless of if the ai script has tha path or not.
i am using Recast graph and send the position via ai.destination = vector3
then call
ai.SetPath(null);
ai.canSearch = false; // To prevent it from recalculating the path
ai.canMove = false;
in the middle of its journey. It stops as expected but as soon as canSearch and canMove are true again, it still continues to the same position.
The only way i can get around this is to put -
ai.destination = transform.position;