Hi everybody! I’m developing a set of agents that could die. When an agent die, i use navMeshAgent.Stop() but the agent continue moving. This not always occur. I also try set updatePosition and updateRotation to false and the finally, the problem is the same.
I have cheked that my agents isn’t being moved by others scripts and isKinematic(in RigiBody) is true.
For move my agents i use SetDestination();
What can i do for stop the movement of my agents??
You could try, agent.velocity = Vector3.zero. But I’m pretty sure .stop() or if 5.6 (isAgentStopped = true) should do the same thing. Are you sure you are not calling .Start() somewhere else or that Stop() is being called…try throughing a debug line in there after .Stop() and see if it is being called when this occurs.
Try disabling the NavAgent. It sucks, but I had a similar issue that was solved by doing this.
If stopping doesn’t work (and you’re not resuming the agent) then it sounds like a bug - a bug report with a (preferrably small) repro case is appreciated. Please note that the stopping behaviour is controlled by the acceleration of the agent - so if you want to stop the agent on the spot use:
agent.isStopped = true; // was agent.Stop();
agent.velocity = Vector3.zero;
As I was experiencing a similar issue, a solution was to call agent.ResetPath();
as @sarynth has mention above, this will clear the path of my agent and stop the agent from moving