Navmesh not taking shortest path

Hi I’m struggling with my AI not taking shortest path(see img), I guess its my navmesh properties that are not right, any advice on how to fix this? Thanks in advance :slight_smile:



Update: in the original example I used several cubes, but when I test with only one long cube it finds the shortest path…

I can recreate the problem, but have no idea how to fix it. Alternatively, I would suggest using a library that can find the shortest path between two points in a maze:

PathFinding.js (

thanks will check it out :+1:

cc @Cedric

This is a weird behavior I can’t explain. I guess it’s the multiple boxes that create extra triangles in the navmesh. Hard to say without a c++ repro and debugging.

Maybe be related and if so would be a known problem with Recast (not Babylon). See here Not direct path in some situations · Issue #239 · recastnavigation/recastnavigation · GitHub :frowning:

1 Like

A workaround is to have less nodes to traverse.

I think it’s possible to fix it by increasing navmesh simplification. It will give a more uniformly tesselated mesh and a* will work better.

1 Like

thanks :slight_smile: by any chance, what settings did you use?

I didn’t find a good method that works well and for sure.
But, a good start is to have a good minRegionArea and then tweak other values. It seems removing small area where agents can’t go, simplifies the geometry substancialy.
Best is to tweak the input geometry in this case.