0 votes

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??

in Engine by (489 points)

1 Answer

0 votes

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(...)
by (3,239 points)

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?

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.

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?

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()

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?

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.