Sometimes reachEndOfPath returns false when the route has actually ended

sometimes reachEndOfPath returns false when the route has actually ended, I saw that to check if a route is finished you have to check it with this condition (! this.agent.pathPending && this.agent.reachedEndOfPath), I have to add to the condition this ((! this.agent.pathPending && this.agent.reachedEndOfPath) || (transform.position==this.agent.destination)) so that it really checks if it has reached its final destination. why does connectedEndOfPath return true sometimes? thx

Hi

reachedEndOfPath will be true if the agent has detected that is has reached the end of the path it is currently following. If you for example change the destination it may take a few frames for the path to be calculated and the agent starts following the new one.

In most cases I recommend that you use reachedDestination instead which is much less error prone.

This is all in the documentation:
https://arongranberg.com/astar/docs/iastarai.html#reachedEndOfPath
https://arongranberg.com/astar/docs/iastarai.html#reachedDestination

1 Like

Hello, sincerely reachedEndOfPath is giving me better results than reachDestination because it recognizes its final destination before, if I add the condition that I mentioned above it will be perfect. Thank you anyway!