Path:ComputeAsync() slows down the more it is called

I am making a game where there are many waves of monsters that attack, each monster utilizing pathfinding since each map is randomly generated. I am testing how 100 of the smallest monster would do and a lot are pathfinding fine. The others, though, would take an extremely long time to compute a path. There are two issues that I need help with.

  1. I have the monsters compute a path and check if the path is blocked on a loop until the path is clear. When I make it so that there is no way to get to the goal and then create a way to get to the goal after about 15 seconds of waiting, the time the monsters use to compute a single path increases drastically and does not lower at all after.

  2. Even when the path isn’t blocked, some monsters still take a very long time computing a path. I thought this was because they were so far away from the goal, but then I saw that other monsters that spawned even further from the goal than them could pathfind without issue.

Am I using the path:ComputeAsync() function way too much? Is there a way to fix this? I need to know so I don’t waste my time on this if there is some hard-coded limit.

1 Like

I am not really someone who promotes third-party projects for everything, but this time I make an exception.

The Polaris-Nav project is maybe the best solution once it’s released. Polaris-Nav is basically superior at all aspects to the Roblox Pathfinder and even allows offloading to external servers for a subscription, allowing calculations of lightning speed! The best of it? It’s free and easy to use when available! :tada:

I have not created Polaris-Nav and my ‘pitch’ is all based on my own enthusiasm of the project. I am not sponsored to encourage this solution, as it is all from my own excitement.