I’m working on a scene where nav mesh is updated after the user add objects to it. I start with a plane and add cubes to it. The nav mesh should be updated by restricting the navigation of the plane because of the new obstacle, and a new nav mesh should be generated on top of the cube. But I found that if my new object is placed inside a tile, the new nav mesh for the cube is not generated, while if I place it “breaking” the tiling (so the cube is in two tiles) then the nav mesh is generated. Is this the expected behaviour or is it a bug? I could reduce the tiling, but that’s not what I want actually. I add some pictures to explain it better.
The NavMesh is built in parallel as a grid of tiles. If an area straddles a tile boundary, the area is not removed. The reason for this is that the area pruning happens at a stage in the build process where surrounding tiles are not accessible.
I actually don’t want it to be removed. So the problem seems to be that my object is smaller than the “Min Region Area”. Is the “Min Region Area” the same as the tile size? Or how can I control it when baking at runtime?
hmm seems to be not exposed to runtime navmesh building for no obvious reason … an ommision on my part - sry…
I’ll try to patch this asap …
In the meantime - if you need a workaround you can use reflection to set the min. region area:
using System.Reflection;
...
// assuming the 'buildSettings' variable is available here
// Warning : nasty, dirty reflection kludge here
var t = typeof (UnityEngine.AI.NavMeshBuildSettings);
object boxedSettings = new UnityEngine.AI.NavMeshBuildSettings();
boxedSettings = buildSettings;
t.GetField ("m_MinRegionArea", BindingFlags.NonPublic | BindingFlags.Instance).SetValue (boxedSettings, 0.0f);
buildSettings = (NavMeshBuildSettings)boxedSettings;
// 'buildSettings' has min region area of 0
...