- Home /
Recentering an infinite world that has a NavMesh.
I have an infinite world consisting of Terrain tiles. Every time a new set of Tiles are created (and old ones deleted), we have to recenter the world to avoid floating point issues when traversing too far from the center of the map. This works decently, beside two severe issues with the NavMesh.
The first one is a performance problem with the generation of the NavMesh every time new tiles are added. We use the new NavMeshSurface component that allows for runtime building, but even with asynchronous building it has a noticable lag spike. We'd like to generate the NavMesh using our own methods in a separate thread. Unfortunately even though the NavMesh has a method CalculateTriangulation() to retrieve the triangulation, I couldn't find a way to actaually SET the triangulation. I've done some work on recast and detour (to my understanding the underlaying system) before, and can't understand why this option is disabled.
The second problem is recentering the NavMeshAgents. The NavMeshAgents have total control over the GameObjects transform, as they should have. But this also means that when we want to recenter, we'd like to also manually change all the waypoints in their current path so that the internal position of the NavMeshAgent would recenter as well.
I've started writing my own system from scratch based on detour, but feels it stupid to do something that will be 95% the same as Unity's system.
TL;DR Need a performant way to assign a custom triangulation to the NavMesh for runtime generation + need a way to recenter the paths of the NavMeshAgents when the world is recentered.