NavigationMesh size issues

Godot Version



I faced several issues with size and shape of NavigationMesh.

I started with creating the floor: I used StaticBody3D (CollisionShape3D + MeshInstance3D), set NavigationRegion3D as its parent node and baked NavigationMesh. The first problem is the size of the mesh, it is much smaller than the floor size.

I guess these gaps should prevent collisions with walls, but I hope there is a way to reduce them.

Than I added an obstacle (a bed object) as a child of NavigationRegion3D, another StaticBody3D (CollisionShape3D + MeshInstance3D) and baked NavMesh. There another problem: baked mesh is overlapping the obstacle:

I tried to add NavigationObstacle3D to StaticBody3D, but it makes no different no matter how tall the NavigationObstacle3D is.

The only sollution I found, I added another box MesInstance3D to the bed:

With this hided mesh overlap is gone:

But now I have even smaller navigation region. It looks odd.

How could I fix it?

I think the navigation mesh documentation that you find here Using navigation meshes — Godot Engine (latest) documentation in English could help answer many of your questions.

The first part explains why a navigation mesh smaller than a floor, at least with default bake settings as the agent radius shrinks the available surface as an offset. A navigation mesh surface is for the center of an agent, if there is no offset your agent will get stuck on physics collision or fall down ledges all the time.

It also explains the agent bake settings and other properties in the NavigationRegion3D bake sections. E.g. that there is navigation mesh on top of your “bed” is because there is enough surface area for an agent radius to stand on. You already found the solution to that by placing another shape there that makes the surface no longer usable.

You baked with a very, very low height voxel cell size. Likely because you wanted to navigation mesh to hug the ground, but that is not its purpose and will also not work around slopes or ramps. A navigation mesh is an abstraction and will regularly not follow the ground closely so do not build with the assumption that this will reliably work. Having such a low cell height is also a performance problem as it requires the baking to create an excessive amount of voxels.

1 Like

Thank you very much for the detailed reply.

[quote=“smix8, post:2, topic:63212”]
E.g. that there is navigation mesh on top of your “bed” is because there is enough surface area for an agent radius to stand on. [/quote]
I have reduced an agent radius (and max climb), now it looks much better. The only thing is still confusing me is a offset for the bed sides. Why it is double wider than offset for the bed front?

The baking rasterizes the source geometry into a voxel grid. These kind of “off-by-1-cell artifacts” are a result of how the mesh geometry got mapped into the cells and how the spans and areas got calculated in the baking process.

If you imagine a grid on top of your image you can see that the left and right side of the bed have some slight overhang so those cells to the left and right of the bed that are mostly empty are still marked as “obstructed”. Since all units in the baking are cell units the only way to have agent_radius offset to the bed is to move one cell away from it.

1 Like