Repathing dozens of seekers at the same time

Hi, I was wondering what the most efficient way of recalculating paths for dozens of objects after using UpdateGraphs on a new obstacle’s bounds?

The only way I can think of doing it is by calling StartPath again on each one of my objects, but that seems like it’d be very slow if I had a lot of objects (think tower defense).

Does anyone have an idea of what I should do? I tried looking at the example projects but I wasn’t sure what to look for.

For a TD game, you might want to check the FloodPath and FloodPathTracer path types. If all your pathfinding queries are from one units position to the same point (the goal) for all units or at least to a very low number of points. You could use the FloodPath to calculate paths a single time which can then be used to get all possible paths to that exact point.

See http://arongranberg.com/astar/docs/class_pathfinding_1_1_flood_path.php#details
(the large NOTE message there can however be skipped, that has been fixed, but I have not updated the docs for it yet).

The above assumes you are using the pro version.

If you just want to recalculate a large number of paths, there is not really a lot to do except to call StartPath on them. The system will spread out the pathfinding calculations over multiple frames however, so you should not worry too much about a huge lag at that point. You could loop through their existing paths and check if the path goes through the region which was updated and only if that is the case, recalculate the path.