Hi all!
I use the Unity Nav Mesh Components for fairly large nav meshs and a lot of agents.
I am facing two major problems, in brief:
- The calculation for paths takes very, very long.
- The number of simultaneously calculated paths seems to be limited.
Problem 1:
I have different map sizes, starting at 32x32 unity units. On this map size, the nav mesh works pretty well without any major problems. The largest size I currently have is 64x64, where it takes around half a minute on average to calculate paths. I actually plan to have larger maps but I currently can’t due to this limits. The picture shows the larger map.
I tried to do a lot of different things to get the complexity of the nav mesh down as much as possible and I think it’s not that bad compared to other meshes I see.
The problem might be that there are too many calculations pending, which leads me to the next problem.
Problem 2:
This is kind of connected to the first problem. During my tests, I gradually increased NavMesh.pathfindingIterationsPerFrame but I feel like this doesn’t change anything. Whether I set it to 500 (the recommended max.) or 10000, it doesn’t change anything in regards of calculation time.
I tried to set this value to crazy numbers just to test if the FPS would actually drain and maybe find a sweet spot or anything but I can still run the game with over 1000 agents on 30 FPS in editor, no matter how high I set this value. I assume there might be a max. set within the Nav Mesh Components.
As a solution I tried to only calculate partial paths and then, once an agent reached a partial destination calculate the next one and so on but this doesn’t work too well either.
The request:
So what I was wondering is if there are options to do the following:
- Actually change the amount of paths being calculated per frame
- Prioritize different calculations (this would help a lot already)
- Multi-thread this entire thing (it’s not from my understanding)
- Maybe have a way to reduce the mesh complexity
tl;dr:
What are the tricks and tips to get performance out of the nav mesh components?
If possible, I’d like to keep the Unity implementation of the nav mesh because changing that to something else (like the awesome A* project) would mean a lot of work and the amount of optimization I did with the unity stuff is fairly large.
Happy for all inputs and ideas!
Thank you!
Johannes


