NavMeshAgent priority levels quantity is too small

Hi, is there any way to increase the NavMeshAgents priority level above 99? I need it for making an RTS with hundreds or thousands of units on screen. I want to use it to make units not overlap in various situations. 100 positions is also very bizarre, it’s an Integer, so why only 100 values?

I have made various systems such as moving in formations or keeping group shapes, moving around corners with a random distance for big groups, etc…

But it’s still not enough. For example a group of units attacking a single unit ends up having all units overlap pretty hard. If units that are closer to the target had a higher priority, it would reduce the overlap significantly. But I need to have 100.000 to 1.000.000 priority levels to an achieve this.

Thanks for your time!

1 Like

The problem is not the number of missing priorities. The avoidance implemented is just not good enough to handle a lot of agents.

If you are planning to make a full-blown RTS I would recommend going with either A* Pathfinding Project or Agents Navigation when you want to stick to the Unity internal navigation mesh creation.

1 Like

Aaaaactually. I’ve just fixed the problem. When having 100+ agents on screen moving to a single target position, they start overlapping, stuttering and being pushed around. I’m posting this for anyone who wants to fix this in the future:

The problem is not that the units push each other too hard. The problem is that they are trying to avoid each other, and when they see that they are going to collide with a big group of agents, they freak out.

Here’s the fix:
Set NavMesh.avoidancePredictionTime to a value of 0.5f (2.0 is the default, be aware that if you remove the line afterwards the value will stay saved in Unity until you restart it for some reason). This immediately fixed the issue. Now I can have 10.000+ units on screen moving together to a single target or going around a corner. And they do it 100% smoothly. No overlapping, jittering or pushing. I also have the NavMeshAgents avoidance quality set to High but that might be irrelevant.

I hope this helps someone in need, as I couldn’t find a solution to this problem online for nearly half a decade.

Everyone online has told me to use some sort of plugin but honestly, the more I stuck to Unity’s NavMeshAgents, the more I learned on how to make proper systems for groups. And in the end I managed to do everything I wanted to do. I just wish that Unity made the built in systems more customizable and easy to use. AND ALSO MULTI-THREADED PATHFINDING PLEASE.

Great that you found a solution to your problem.
I have tried this setting with different values. The avoidance is still not on the level of the linked plugins above. In my setup, targets don’t get properly surrounded, and agents are still pushed into each other.