In the Navigation Manual there is a HowTo for “Making an Agent Patrol Between a Set of Points” which acquires the next waypoint for a NavMeshAgent in Update() which resulted in skipping some waypoints when copying it in my project.
I suppose that’s because you should not poll agent.remainingDistance
as that property is not updated immediately after getting a new destination but rather after some frames (?).
An easy fix would be to just combine it with the agent.pathPending
property thus delaying the proximity check until the pathfinding is done without refactoring the rest of the tutorial code.
Problem:
void Update () {
// Choose the next destination point when the agent gets
// close to the current one.
if (agent.remainingDistance < 0.5f)
GotoNextPoint();
}
Fix:
void Update () {
// Choose the next destination point when the agent gets
// close to the current one.
if (!agent.pathPending && agent.remainingDistance < 0.5f) {
GotoNextPoint();
}
}
Hope that helps and this is the correct place to post these kinds of issues.
Regards,
lt