A* Pathfinding Project

Totally cancel a navigation request


#1

Hi,

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?

Thanks!


#2

Hi

You can use

ai.SetPath(null);
ai.canSearch = false; // To prevent it from recalculating the path

If you want to stop the agent immediately without it smoothly slowing down then use

ai.SetPath(null);
ai.canSearch = false; // To prevent it from recalculating the path
ai.canMove = false;