Moving 500+ units without queuing

Hi there,

I am trying to get 500 units march towards their individual targets but it seems that the pathfinding gets queued up when the number of units exceed a certain amount. I am using NavMesh with the A* Pathfinding Pro version. Below are screenshots to illustrate the issue.

Beginning (this is 136 units only, not 500)

Some units get left behind as if waiting for their turn. When some units die, they will commence their path

This was a problem that occured even with Unity’s NavMesh system but was able to resolve it by setting
NavMesh.pathfindingIterationsPerFrame to a large number, basically increasing the max number of nodes processed per frame.

I have played with setting Threadcount in the AStar Component but it doesn’t seem to have any affect.
What can I do to make all units run at the same time (or close to)?



You can make path requests synchronous so that they are calculated immediately.
This requires a small change to the movement script you are using.
The movement script likely calls the seeker with a line that looks like


change that to

var p = seeker.StartPath(...);

However one thing that might be happening in your case is that pathfinding is fast enough, but modifiers are taking some time so the system has to throttle those. Currently this time limit is hardcoded to 1 ms per frame, though I really should change that to be dynamic. In any case you can increase it in the file PathReturnQueue.cs. Look for the line starting with ‘long targetTick’.

1 Like

Hey aron,

BlockUntilCalculated() worked!
Thanks for the solution.

1 Like