Unity allows the runtime generation of NavMesh surfaces with the Unity.AI.Navigation package through the BuildNavMesh method. However, this function re-bakes the entire NavMesh in the current scene, which is very expensive. Is there any way to only bake for a specific area? e.g. within the radius of a Vector3 position, or within some defined grid?
1 Answer
\$\begingroup\$
\$\endgroup\$
1
A NavMeshSurface component only takes into consideration the geometry defined in its children, not the whole scene, so you can have multiple surfaces and only rebake one at a time. It's not quite as much granularity as you want, but I don't think you can go finer than that (other than obstacles with cutting enabled, but I imagine that's not what you mean).
-
\$\begingroup\$ Seems like this could work. I could maybe divide a large terrain into several smaller ones, set them to only consider it's children, and then re-bake only one of the terrains if needed. But is there an easy way to connect the different NavMeshes to each other, so they're acting as if they're one connected NavMesh? This would be required for the solution to work \$\endgroup\$Alec McKay– Alec McKay2023-12-05 05:00:05 +00:00Commented Dec 5, 2023 at 5:00