Hi,
I would like to do high-performance pathfinding using Unity’s navmesh system. However, the current built-in functionality for pathfinding - either by using NavMeshAgent or the asynchronous NavMeshQuery - creates garbage and causes regular GC events (and thus latency spikes) at around 100 agents.
Incremental GC isn’t really a solution, and in my tests it was hardly helpful. I still get latency spikes that reduce my framerate from 200-300 to less than 90 every 5-10 seconds. With pathfinding turned off, I don’t get any GC events because the rest of my code uses structs and the Job system.
This is really a shame because:
- Pathfinding is a core feature of most games.
- Nowadays it’s totally possible to build an otherwise garbage-free game using structs and the Job system.
- GC events are extremely detrimental for VR applications where steady framerate is absolutely critical.
- Most of the advice on the internet currently is “use Incremental GC” but this is a marginal improvement at best.
I’m creating this thread to voice my opinion and get feedback from the Unity team. I really hope this is on your backlog.