Navigation agent getting stuck while pathfinding

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

I have no idea why my agent gets stuck. As seen in the photo, there is plenty of space to go through.

:bust_in_silhouette: Reply From: dango1

I also get an error that says

E 0:00:07.333 sync: Attempted to merge a navigation mesh triangle edge with another already-merged edge. This happens when the current cell_size is different from the one used to generate the navigation mesh. This will cause navigation problems.
<C++ Source> modules/navigation/nav_map.cpp:582 @ sync()

cant get over this piece of work

dango1 | 2023-02-13 16:39

:bust_in_silhouette: Reply From: smix8

Because your navigation mesh or region setup is broken / corrupted.

The error you get hints at overlap / intersections in your navigation mesh / regions. This in turn makes the NavigationServer fail the merge of the navigation polygon edges hence your entire pathfinding breaks.

The visuals in the Editors can not reflect this corruption cause they only read the polygons from the single NavigationMesh used in a NavigationRegion while the corruption happens on the NavigationServer with the navigation map sync that handles all navigation meshes combined.

Hello good sir,
I have managed get rig of the error by scaling everything up 10x. However, when using the same method from the navigation demo
https://godotengine.org/asset-library/asset/124

my position3d node with the mesh attached goes through the wall instead of going through the door as showed in the image here
plm hosted at ImgBB — ImgBB

I am really losing my mind over this as I don’t know what is happening while being stuck on the same problem for weeks now.

dango1 | 2023-02-28 19:50

You should not need to change scale on any source geometry for the navigation mesh baking to work, instead change the cell size and cell height on the NavigationMesh bake properties.

In fact everything should preferably be at scale 1.0 as up / downscaling models and collision shapes adds a growing amount of precision issues to the baking which can lead to polygons edges getting matched wrong and also triggering that original error msg you had.

If you use a 3D model that is at a very inappropriate scale for Godot e.g. FBX that is like 0.01 from Godot scale, you should fix the scaling first in a DCC software before you import the fixed model to Godot.

That demo you linked is a little outdated but you can use the updated Godot 4.0 navigation documentation and examples as it uses the same baking system.

smix8 | 2023-03-01 08:35

There is a problem with that… Some meshes are attached to other nodes, and when you have procedural geometry, you cant make meshes procedurally while keeping scale…

node(certain scale, procedurally generated)
|
|-----mesh(scale 1:1:1)

navmesh
|
| ----- meshCopy(scale modified to keep the apparent size consistent)

Kem | 2023-05-09 15:32

:bust_in_silhouette: Reply From: Kem

Try to use NavigationServer.MapSetCellSize() on your current map if you modified the cell size of the navmesh in the editor.
And i think you should make the map correspond to the navmeshinstance settings.