Hello all. I’ve been using Astar Pathfinding Project for a 2d topdown game on Unity so the enemies can follow the player around the map. Works fine, except if the player gets too far away from the enemy using Astar, the path will stop updating and remain as the path when the player got out of range. Then when the enemy reaches the end of the path, it will recalculate a new path to the player (despite the player being far away). I’ve checked and my code is properly calling for a new path every Fixed Update with proper inputs, but somewhere in the Astar code, I think it is stopping new paths from being properly generated. Please help!
Path requests are asynchronous, so if you call StartPath every FixedUpdate it might not have had time to calculate the previous path you wanted it to calculate (especially if the path was long). The result is that it never calculates anything because every FixedUpdate you abort the previous calculation and start a new one.
Instead, only recalculate the path is
seeker.IsDone() returns true.
See also Documentation
Thanks so much for the quick response. That makes sense. I’ll have to make the nodes bigger and adjust things accordingly.