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