Can I merge baked navigation meshes under one Navigation node?

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

Hi All, I’ve seen this question asked before but haven’t seen any answers. I am wondering if it is possible to create ‘modules’ of a level as baked navi meshes and parent them to the same navigation node and have pathfinding work across those navigation meshes? I’ve tried and so far no luck - my node stops at the boundary of the first navi mesh and refuses to cross over onto the other (which is perfectly aligned, too). Any new developments of this subject??

:bust_in_silhouette: Reply From: Magso

Save the NavigationMesh resources, store them into an array and use code like this.

$Navigation/NavigationMeshInstance.set_navigation_mesh(navigation_mesh_array[wanted_mesh])
$Navigation.get_simple_path(...)

How do I save the mesh instance as a resource? The node has other meshes etc as its children. Do I just save the branch as a resource?

Macryc | 2020-03-31 15:19

Back the navigation mesh and save the NavigationMesh resource.

I tried to upload an image but it doesn’t seem to work.

Go to the navmesh property in the inspector, click the dropdown menu and there’s the save option.

Magso | 2020-03-31 15:36

I don’t think I’m getting this:(.
The code above looks like you’re assigning a baked navimesh to a NavigationMeshIstance node. Why would you do that if the NavigationMeshIstance already has a baked mesh assigned to it (in the property: Navmesh)?

My question was more about whether you can have multiple NavigationMeshIstance nodes, each with a baked navimesh assigned to it (with resources, other nodes, etc, parented to it) placed beside each other, all parented to the Navigation node, and have path finding across those NavigationMeshIstance nodes?

Macryc | 2020-03-31 16:22

Basically that won’t work without rearranging the child NavigationMeshIstances and honestly you raise a good point here, get_simple_path could do with an extra argument to define which NavigationMeshIstance to use to get the path. As of now you can use move_child().

$Navigation.move_child($Navigation/NavigationMeshIstance, 0)
$Navigation.get_simple_path()

Magso | 2020-03-31 17:15

Ah, this is an interesting tactic. Does that mean that the Navigation node only finds paths on that NavigationMeshIstance node which is its closest child?

Macryc | 2020-03-31 17:21

Ahh ok, I thought it worked with the first child (from an old test that I’ve just had to fix) but I’ve just tested it and if there are two NavigationMeshInstances with different NavigationMeshes, get_simple_path returns [] absolutely zilch. So it’s a case of using remove_child and add_child on the NavigationMeshInstances or swapping the resource like what I originally said.

p.s. “from an old test that I’ve just had to fix” don’t mix up NavigationMeshInstances with MeshInstances like I did XD

Magso | 2020-03-31 17:48