What's the structual intention of the Navigation family of nodes?

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

Hi, I’m trying to figure out Godot’s 3D navigation / navmesh system, but I’m having trouble. There’s very little documentation and I’ve only found one rough tutorial on YouTube. What I want to know most of all is, how is it meant to be used?

From what I’ve seen in that YouTube tutorial here: https://www.youtube.com/watch?v=_urHlep2P84&t=328s and read in the documentation here: Navigation — Godot Engine (3.1) documentation in English the Navigation node has NavigationMesh children which have MeshInstance children, and then when you select the NavigationMesh you get a Bake Navmesh button that bakes a Navmesh based on the geometry of the NavigationMesh childen.

Does this mean the Navigation node should be the root node of any scene with world geometry, and the world geometry all a child of a NavigationMesh?

But here’s the tricky bit, you can have more than one NavigationMesh child for a Navigation node, with different Navmeshes calculated for different mobiles to use. IE A player, a small enemy, and a big enemy. These navmeshes are created using the same geometry, then saved as a resource and plugged into the NavigationMesh nodes. So it’s possible to generate navmeshes and put them into the Navigation system without having it sit at the root of the tree.

So what I’m thinking is, what if you’re ‘supposed’ to have the Navigation node not as the root of the tree but as another same-level node, fed pregenerated Navmeshes? The trouble with this is, if the Navigation node and its NavigationMesh child aren’t containing the level geometry, you’d have to make another Navigation node and NavigationMesh node holding the level geometry just to bake the navmeshes each time you made a change, right? This seems inconvenient. The other alternative would be to double my level geometry just for baking navmeshes but that seems like a bad idea too.

So my problem is, I’m not sure how the Navigation node and system are meant to be used in Godot’s already existing structural system. There’s plenty of documentation on how Godot is meant to work, though of course you can change it… But there’s no info on how to use the Navigation node and system.

So how is the Navigation node and system meant to be used?

:bust_in_silhouette: Reply From: Zylann

Assuming the 3D version of Navigation follows the same logic as Navigation2D, you are right. A Navigation node gathers all navigation meshes it finds down its hierarchy and uses them to form the global navmesh for agents to generate paths from.

The idea of multiple layers of navmeshes is a good point. I haven’t had to handle this situation yet, but the tree structure makes it impossible to accomplish this goal without changing the API and introducing some kind of “layer” parameter on all functions. Maybe that could be requested to change in the future (if nobody asked already?).

In the meantime you could separate multiple Navigation nodes on their own as child of the level, and move navigation meshes for each specific layers under one of them. That could be done through a bit of scripting, but completely destroys the usefulness of the scene system…

So I’m curious myself how this may be handled in the future.