Unfortunately thereās nothing I can add, and I feel navigation is probably understaffed from what I can imagine. Certainly itās very capable but has a ton of these little quirks. Are you using the github version?
A quick fix in your case if you want to continue using the agent is to just call stop or set destination where it is before telling it the path is complete. When an agent has control, telling it to complete isnāt āstop calculating movementā but ācomplete it!ā, so try some func calls like ResetPath and so on. Have a filddle till it stops being daft and donāt assume it means what you think it means (the thinking behind navmesh is a little different to the rest of Unityās API and thatās becoming the norm these days I guess).
ā
In my case I never actually use the agent itself for movement but disable position and rotation updates inside init with:
agent.updatePosition = false;
agent.updateRotation = false;
Then I update it myself each frame (not sure how much I need to do here):
agent.speed = actor.properties.speed;
agent.velocity = actor.controller.rb.velocity;
agent.nextPosition = actor.transform.position;
And finally grab the intended velocity when needed from:
agent.desiredVelocity
To apply movement myself, be it a direction vector (with some extra code) or just used as-is with agent settings. This will cause character to also collide with environment but should your character be knocked off course and have auto repath enabled, the above code will calculate a new path, so you can properly control a creature or whatever physically or otherwise.
A quick fix in your case if you want to continue using the agent is to just call stop or set destination where it is before telling it the path is complete.
Not sure why Iām doing AI support but if it helps, it helps! This section of the forum is often unloved.
Edit: added a couple of old methods from my code - untested for the longest time as Iāve not been working on AI for a while but you may find a glimmer of interestā¦
public void StopMoving()
{
if (agent.isOnNavMesh)
{
agent.CompleteOffMeshLink();
agent.ResetPath();
}
}
public bool Arrived()
{
return !agent.pathPending && agent.remainingDistance < agent.stoppingDistance;
}