I have some NavMeshAgents in my game and every so often, one of them will get stuck. It appears that the agent’s path is getting cleared out from inside the Agent update function. It appears to happen only after stopping and resuming the agent at least once.
I have tried the following things to remedy the problem:
- Use SetDestination()
- Use .destination
- Use CalculatePath() (comes back valid) and then set .path
- Use CalculatePath() (comes back valid) and then use SetPath
- Detect whether the destination is not what I set it to and set it using SetDestination()
- Enable & Disable the NavMeshAgent instead of using Stop & Resume
- Destroy and recreate the NavMeshAgent when I detect the bug is happening
But none of this fixes the problem. The following update frame, pathPending is set to false and the path is cleared out. The ‘corners’ of the path (which was a straight line, 2 points of current agent position and destination when made with CalculatePath() and set with SetDestination()) now only contains the current position of the agent.
I’ve checked that ResetPath is not being called. The destination and path of the agent are not being changed by my scripts anywhere in between my setting the desired destination and the path being destroyed.
Has anyone seen this kind of behaviour before? Is this a new bug? I’m on 5.3.2p2 (for Particle resetting fixes). I’ve also tested on 5.2.4f1 and had the same behaviour.