[Godot 3.4.4] Baked navmesh seems to hover above the NavigationMeshInstance

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By saladdodger

I’m trying to add navigation to my project. I’ve seen a couple of tutorials on YouTube about doing so. Both followed the same hierarchy:

– Navigation
– – NavigationMeshInstance
– – – A couple of MeshInstances

In the tutorials, whenever they pressed bake, the navmesh appeared as expected. On the ground, with cut outs where the ground is not walkable due to box meshes.

I’ve tried the same, but my navmesh appears to be hovering above the ground.

The navmesh appears to be going through some mesh instances.

The navmesh appears to be hovering above the ground.

I’ve tried the same in a brand new project, but had the same results. I’ve also tried to play with the settings of the navmesh, but it didn’t seem to help much. The only thing I noticed was that the navmesh got a bit closer to the ground when changing the Cell Height, but even then it was still hovering above the ground.

I’m sure I’m doing something wrong, and look forward to hear what that is :stuck_out_tongue:

:bust_in_silhouette: Reply From: smix8

This is expected. A bakednavigation mesh is an approximation of the source geomtry for both performance and technical reasons.

The baked navigation mesh will always hover roughly around cell size height but especially on uneven ground like ramps this margin will not be kept and it might clip through plenty of uneven surfaces. You never should assume that your navigation mesh keeps an equal distance to your ground geometry. Use e.g. physics collisions to place your agents on ground. The NavigationAgent also has an offset property that deducts a certain height from all path points so if you use a very large cell height you can reduce the “hover distance” for the path points futurer justn to low or you agent might clip into ground.

Also you can not reliably use “boxes” to cut out navigation mesh baking areas. The baking process has no concept of what is “inside” and as soon as there is enough space to fit an agent in you will create navigation mesh surface inside those boxes. You should in general limit your bake source geometry to the actual traversable surfaces. If this is too complicated to setup in the SceneTree due to parent / child constrains with your source geometry you can use the NavigationMesh bake group names to limit the baking to specific nodes of a group.