Closed Norodix closed 1 year ago
I tested with Godot 4.03 stable and the issue is present there as well.
The reason why the pathfinding is broken is because the cell_size
that you use to bake the navigation mesh is not the cell_size
used on the navigation map that later uses the navigation mesh.
The navigation map can not rasterize the vertices and edges of your navigation mesh correctly with such a mismatch resulting in broken pathfinding.
You can change the cell_size for the default navigation map in the ProjectSettings in the Navigation->3D tab or you can use the NavigationServer3D.map_set_cell_size()
API function to fix this.
Please do not ignore rather clear red error warnings with information that the engine already gives you.
This error is both displayed directly at the project load as well as at every game start in Godot 4.1.
In Godot 4.03 the error msg is less detailed but the general warning about navigation map synchronization error is still there.
Thanks, it seems to work now!
I do not generally ignore big red errors but searching for navigation map didn't bring up anything useful. Navigation map is not a resource I added when I followed the official documentation so I did not know where to look for these settings.
I even checked the navigation menu in project settings but "default cell size" does not sound at all related to this issue. I dont have a problem with the defaults, I have a problem with the changed values.
I also assumed that it is related to this line in the example code.
# Wait for the first physics frame so the NavigationServer can sync.
await get_tree().physics_frame
Because this one has actually similar wording unlike the project settings that relate to it.
They might be very clearly errors but they are not clear errors at all.
Anyway, thanks for helping me find the problem, its a big relief!
@Norodix Genuine question since you did not find this information or could not connect the dots between error and the problem.
How would you better word the errors to make it more clear or where would you place this information so it can be better found?
It is a common error for users to have mismatched cell sizes hence why the error msg was improved in Godot 4.1 and additional errors were added. It still seems to be an issue, you are not the only one that stumbles over it, just one of the few that made an official issue to talk about it.
To me based on the explanation in the docs (the sections that I came across) the concept is not 100% clear.
I understand the navmesh is created by somehow using these cells to triangulate the area that can be safely walked on. But why does the navigation map need the cell size any more? I thought the pathfinding happens on the created navigation mesh. So it did not cross my mind it would matter after the navigation mesh is created. This is my shortcoming but also normally expected from someone not very familiar with navmeshes.
Regarding the errors, the setting that actually modifies the navigation map's cell size is called default cell size. To me that is not descriptive because I did not have a strong understanding of how navigation map relates to the navigation area and why the default would determine the navigation map's properties.
Admittedly I'm in a 2 day gamejam so I am in a hurry and I did not take as much time to try and understand what is happening as otherwise I would. But to me the problem seemed so clear. I could see the navigation mesh, the agent could walk on it and perform pathfinding on it. It didn't seem like it could be a problem with the mesh. I was convinced the agent's pathfinding was the problem.
I'm not sure I'm helping with my rambling but this is my current understanding as a beginner in the topic.
Sleeping on it one more thing comes to mind. I came back multiple times to this page to see if I messed something up.
https://docs.godotengine.org/en/stable/tutorials/navigation/navigation_introduction_3d.html
If this is a very common issue it might be worth adding an example to this introduction page. But that depends on how common it is. In my case the first thing I changed after copying the example was to mess with the cell size because I have a small agent.
Godot version
v4.1.stable.official [970459615]
System information
Godot v4.1.stable - Pop!_OS 22.04 LTS - Vulkan (Forward+) - dedicated AMD Radeon RX 580 Series (RADV POLARIS10) () - AMD Ryzen 5 5600G with Radeon Graphics (12 Threads)
Issue description
Navigation agents cannot walk through some corridors and doorways.
Navigation mesh is created and an agent is placed in the world. It is moved to a random new position marked by the red sphere every time it completes its current task. The navigation mesh has a valid path through it but the agent cannot find it at all.
The navmesh in the minimal reproduction project is a bit extreme with that narrow corridor. It was a more reliable way to trigger the problem but originally I noticed it on a very normal looking navmesh where the agent could not visit some rooms. Still, the navigation mesh is valid and the agent should be able to walk through it.
Here is video of the agent trying to reach the target marked with a red sphere.
https://github.com/godotengine/godot/assets/36245389/c70a855e-e0ff-44b8-9cac-1a8ff1e87d6e
Just for reference, here is the navmesh where I originally noticed the problem.
As you can see it is a quite wide doorway with nicely formed triangles.
Steps to reproduce
Run the reproduction project. Wait for the agent to target a position on the other side of the barriers and observe the problem.
Minimal reproduction project
NavmeshTest.zip