godot: GridMaps and NavigationMeshes don't work when used together
Godot version: 3.0 OS/device including version: Ubuntu 16.04.4 LTS (Xenial Xerus) Issue description:
Using a Navigation node in combination with a Gridmap does not work. The Navigation Mesh instances in the meshlib are not used.
Steps to reproduce:
Build a meshlib from a scene as follow:
- Spatial
- Plane (mesh instance)
- NavigationMeshInstance
Build a scene as follow:
- Spatial
- Navigation
- Gridmap (using the meshlib)
When using the Navigation.get_simple_path method, it always returns an empty list of points.
Minimal reproduction project:
The above sample project tries to display a list of points returned by Navigation.get_simple_path in the output. It always returns an empty list however, because of this issue. There is more info in the README.txt file in the zip file.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 20 (14 by maintainers)
Ok, I found a solution.
In meshlib just create the following node structure:
Then in the scene place the GridMap below navigation and another NavMeshInstance (not sure if the latter is necessary):
place the tiles as usual.
I created a demo project here: https://github.com/DigitalKI/GodotGridMapNav
This issue explains the limitations in great details but was difficult to find. I suggest the documentation be updated to list them if they are going to be here a while, as the workaround is usable (if you can find it).
Relevant pages:
classes/class_gridmap.htmlclasses/class_meshlibrary.htmltutorials/3d/using_gridmaps.htmlOkay so I’ve been playing around with this and here are my findings:
Navmesh on a Godot generated plane works.
Navmesh on any imported plane does not workand you cannot bake it. (I more carefully recreated the plane in Blender and it did work)I instead made the navmesh in Blender using the
-navmeshmethod mentioned above. Please note do NOT mark your edges as sharp on your navmesh as it will ruin it. I then exported these as .gltf and had to manually text edit all the floating point precision errors e.g. 0.50000001 to the correct values e.g. 0.5. I could then import these into Godot and use them.If you are using complex sized gridmaps you must make sure vertices line up with their neighbours:
As many have mentioned before your vertices on the navmesh must join exactly on their borders
AFAIK this should work. If it doesn’t, either godot’s navmeshes do weird things, or - more likely - your original cube navmeshes don’t link for some reason. Conceptually a navmesh’s topology is just a bunch of connected triangles, which is what allows you to implement things like bridges etc.
I never got to making it support baking or even completely understanding how that works. The workaround here is to not use baking, unfortunately.
Is it possible that this whole issue’s underlying problem is due to baking?
As I go forward testing this feature I realized that there are limitations, or at least, I can’t make it work. It works only with planes, if you use a closed mesh, such as a cube, it doesn’t allow navigation between blocks. A workaround I’m using ritght now is to create the navmesh from a plane, and replace the cube’s. Yet, if we have an irregular cube, or a block with obstacles, those cannot be taken into account. @Anarchid, I think you implemented this feature (https://github.com/godotengine/godot/pull/4302), do you have any suggestion in order to make non plane meshes to work either? I tried to place each GridMap node under a parent MeshNav node and bake, but it does nothing. Even a workaround would be ok, as I know that a total rework of the navigation features is planned for 3.2 (https://github.com/godotengine/godot/pull/15110#issuecomment-408683381). Also @aqnuep have worked on GridMap editor, so your help too is welcome.
This one should probably be added to the 3.1 milestone.
Yeah, that video, I made it time ago, see my comment above: https://github.com/godotengine/godot/issues/17118#issuecomment-458667564
I don’t remember everything about this issue, but I think there was an improvement, made months ago, I’m not sure if this is still an issue.
Well, tried that and still nothing. I just gave up on GridMaps for navigation and just remade all the maps as singular models. At least these meshes connect together if I make multiple “areas” that I can place next to each other. I found it easier and gives me potential to make more uniquely looking rooms. Limitation breeds creativity.
@TheMikirog sorry to hear that, anyhow my guess is that the terrain is not made of planes (I’m referring to MeshInstance’s PlaneMesh), and that’s the only geometry that works, at least for me, I mentioned that:
The only way I heard, to go around that is to create your own navigation mesh in your favorite 3D design tool (Blender?), and create a mesh that have a name that ends with
-navmesh, see this answer in Q&A: https://godotengine.org/qa/16174/how-to-create-a-navmesh-resource-from-an-imported-meshTo my knowledge, the corners (vertices) of each navigation mesh have to match with any other tile’s navesh, or else it won’t work.
Please note, I’m not saying that Godot’s navigation with GridMaps is flawless or does not need any fixes, I’m just trying to make this work on this version with the current status. Yet, in my case, I’m moving to Astar, more code, but more freedom.
This should be added in 3.1.This does not work as explained in the documentation:
Godot 3.1Beta 3 OS: Windows & Linux
NavigationMesh will be seen (when debugging is on). get_simple_path is empty