Recast NavMesh floating agents

I’ve noticed that agents appear to be floating when using the RecastJSPlugin. In the NavMeshParameters “ch” depending on the value the object will be that high off the ground. Is this a bug or do I have to negative position to compensate for this behavior?

https://www.babylonjs-playground.com/#8HNY00

Adding @Cedric our navmesh GURU

In order to create the navmesh, Recast builds a voxel volume from the geometry. the cs and ch parameters are used to define the resolution of that voxel.
Then, the navmesh is triangulated from the voxel.
depending on the polygons and the ch parameter, the navmesh will not be totally accurate regarding the geometry.
You can specify a smaller value for ch or try to tweak the geometry to get more acceptable tolerance.
In this PG, I’ve added a mesh slightly below the plane with a translation lower than the value of ch. So the end of the voxel will be closer to the box.

https://www.babylonjs-playground.com/#8HNY00#1

So if I understand this correctly, we are technically walking on the first voxel layer?

yes, that’s right.

Now before i go doubling up on meshes, this is the foreseeable intended behavior, instead of moving along the bottom of the first layer?

Depending on your geometry and workflow, you can try to tweak the geometry to improve consistency between geometry and navmesh.
Or you can do a raycast from the transform/agent X,Z position toward the ground to retrieve the Y value.

basically observeMoving
boxTNode.position.y -= NavMeshParamerters.ch

?

no, you can’t do that because depending on your geometry, the delta between the navmesh height and the geometry height is 0 < delta < ch. So the delta might not be uniform unless all your planar heights are multiple of ch. And even with multiple of ch for every walkable heights, if you change the geometry, the delta will change.

Thank you Cedric.

1 Like

Hi everyone, I’m new to 3D and the technology. I’m having a problem with the navmesh, is there any solution to make character walk on the ground instead of floating on navmesh like this? How to fix character floating above the ground when using NavMesh in Unity 3D - YouTube

Hi @Jack2 and welcome to the forum

There is no out-of-the-book solution. You can use a raycast to get the ground height, or use collision detection ( Collisions & Triggers | Babylon.js Documentation ) or even physics.
It all depends on your use-case.

1 Like