I’ve added a way to modify the terrain heights in-game, all is working great - the last piece is to update the nav mesh so that AI’s see the new shape of the terrain.
I tried NavMeshSurface.BuildNavMesh() and it works, but is slow - and doesn’t make sense to rebake the mesh for the entire terrain when only a small portion has been modified.
So I set NavMeshSurface.center and NavMeshSurface.size - which “works” - the area in that volume is updated, but the rest of the nav mesh is then gone.
Tried breaking it up in to multiple nav mesh surfaces - but would have to add hundreds of nav mesh links to connect them - and the links don’t work very well on non-flat surfaces.
I tried the LocalNavMeshBuilder.cs script from the github examples - it kinda works but creates a second nav mesh on my terrain, which seems to really confuse the nav agent. This solution would be perfect if it just modified the existing nav mesh.
I tried navMeshSurface.UpdateNavMesh(navMeshSurface.navMeshData) but it doesn’t seem to do anything.
Any suggestions on how to do or what I’m missing? I’ve been reading through old posts but still can’t find how to do. Any help greatly appreciated!