Good practices for NavMesh3D generation

Godot Version

4.7.stable

Context

I’m working on enemy movement/pathfinding. My needs with pathfinding are:

  • Enemies should walk around objects in the scene, like fences, trees and cliffs
  • Enemies should find the ramps that allow them to ascend/descend height-levels in the terrain

I am using a NavigationRegion for this, but I’m getting some complaints from the editor that my geometry is too complex. I’m intending for my terrain to get a bit more complex than this, so I’m a bit worried that I’ll get problems down the line.

  WARNING: modules/navigation_3d/3d/nav_region_builder_3d.cpp:219 - Navigation region synchronization had 4 edge error(s).
  WARNING: More than 2 edges tried to occupy the same map rasterization space.
  WARNING: This causes a logical error in the navigation mesh geometry and is commonly caused by overlap or too densely placed edges.
  WARNING: Consider baking with a higher 'cell_size', greater geometry margin, and less detailed bake objects to cause fewer edges.
  WARNING: Consider lowering the 'navigation/3d/merge_rasterizer_cell_scale' in the project settings.
  WARNING: This warning can be toggled under 'navigation/3d/warnings/navmesh_edge_merge_errors' in the project settings.

I have tried to increase the cell size, but then I get these gaps in the NavMesh.

It also feels like a lot of the generated mesh is unnecessary; the depression and small hill generate a lot of triangles, despite being fully traversable.

The trees also generate a lot of triangles. I could exchange it so they use avoidance rather than carving the NavMesh, but there’s still a lot of geometry.

Question

What are the best practices when solving navigation in these types of levels? I have tried to look up guides but nothing quite fits.

Are there approaches that are better than a NavigationRegion in this context?

Can I set up the geometry of the terrain in some way such that the NavMesh becomes cleaner?

Thanks for any pointers and ideas :folded_hands:

I don’t know what the best practices are. There’s a lot of settings you can tweak to get different result, but I doubt you will get clean navmesh.

I once get that kind of error, but that happens because of 2 NavigationRegion overlapped with each other which might not be your case.

Other method is to create your own navmesh using blender. It is a lot of work but you will have more control on how the triangle will end up. Then in Godot you turn the mesh into navmesh resource using the mesh option.



You can also name your mesh in blender with suffix -navmesh so that Godot will automatically import and convert it to a proper node.

This Youtube video might help explaining the workflow for custom NavMesh assuming you are using Blender.