Hi guys, I need a little help. I'm instantiating terrains at runtime according to the position of the player. Each block is spawned right next to an existing one, of course. Each terrain has its own pre-baked NavMesh assigned to it. This NavMesh is added to the general NavMesh as such: NavMesh.AddNavMeshData(data); Doing that doesn't merge the new NavMesh with the existing one though. If the character approaches a new terrain, he can't walk walk on the NavMesh of that terrain. I know of NavMesh links and such, but it looks like their purpose is different. I'm surprised there's no simple way of doing this. Thank you!
Hello, You should use NavMeshSurface.BuildNavMesh() instead to build each NavMesh chunk on runtime. Maybe this Unity3D tutorial could give you a clue: https://unity3d.com/learn/tutorials/topics/navigation/baking-navmesh-runtime I hope this is what you are looking for. Cheers!
Using NavMeshSurface.BuildNavMesh() seems to defeat the purpose of pre-baking the navmeshes for each object. I think the point of the OP was to build nav meshes on edit time, which might be the more costly operation, and simply add them procedurally at runtime (the only needed computation is merging the existing navmeshes rather than computing them in full again). I am trying to achieve this goal in any case, and adding off mesh links to every side of my precomputed navmesh does not seem like a good way to do it especially since 1. I don't plan to have square meshes, and 2. the agent does not turn the same way on navmesh and on offmesh link, and I don't want them to jump, just traverse normally.
I'm pretty certain it's better to simply generate the NavMesh on runtime instead of prebaking, like mirkoemirbc suggested above. The NavMeshBuilder seems to work iteratively and only rebuilds the areas that have changed. If you make sure to also remove faraway tiles no longer used whenever you add new ones, this should keep the performance footprint on a same-ish level.
Official way of doing it from the manual is to use the navmesh links : https://docs.unity3d.com/Manual/nav-AdditiveLoading.html . A more advanced navmesh link is also available: https://docs.unity3d.com/Manual/class-NavMeshLink.html I admit that the default behaviour feels weird to use, but there is a way to outfit your agents in a custom offmesh link traversal logic : https://docs.unity3d.com/540/Documentation/ScriptReference/NavMeshAgent.CompleteOffMeshLink.html . With it you can achieve good results close to having a single navmesh, with no rebaking and other shenanigans required.