# Recast NavMesh floating agents

**URL:** <https://forum.babylonjs.com/t/recast-navmesh-floating-agents/11770>\
**Category:** Questions\
**Created:** [June 17, 2020, 11:50am UTC](https://forum.babylonjs.com/t/recast-navmesh-floating-agents/11770 "2020-06-17T11:50:01Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![suredelta](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@suredelta](https://forum.babylonjs.com/u/suredelta)\
**Post date:** [June 17, 2020, 11:50am UTC](https://forum.babylonjs.com/t/recast-navmesh-floating-agents/11770/1 "2020-06-17T11:50:01Z")

</div>

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](https://www.babylonjs-playground.com/#8HNY00)

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 17, 2020, 1:27pm UTC](https://forum.babylonjs.com/t/recast-navmesh-floating-agents/11770/2 "2020-06-17T13:27:16Z")

</div>

Adding @Cedric our navmesh GURU

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [June 17, 2020, 1:53pm UTC](https://forum.babylonjs.com/t/recast-navmesh-floating-agents/11770/3 "2020-06-17T13:53:49Z")

</div>

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](https://www.babylonjs-playground.com/#8HNY00#1)

---

<div class="post-metadata">

**Author:** ![suredelta](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@suredelta](https://forum.babylonjs.com/u/suredelta)\
**Post date:** [June 17, 2020, 2:05pm UTC](https://forum.babylonjs.com/t/recast-navmesh-floating-agents/11770/4 "2020-06-17T14:05:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [June 17, 2020, 2:09pm UTC](https://forum.babylonjs.com/t/recast-navmesh-floating-agents/11770/5 "2020-06-17T14:09:40Z")

</div>

yes, that’s right.

---

<div class="post-metadata">

**Author:** ![suredelta](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@suredelta](https://forum.babylonjs.com/u/suredelta)\
**Post date:** [June 17, 2020, 2:23pm UTC](https://forum.babylonjs.com/t/recast-navmesh-floating-agents/11770/6 "2020-06-17T14:23:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [June 17, 2020, 2:25pm UTC](https://forum.babylonjs.com/t/recast-navmesh-floating-agents/11770/7 "2020-06-17T14:25:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![suredelta](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@suredelta](https://forum.babylonjs.com/u/suredelta)\
**Post date:** [June 17, 2020, 2:34pm UTC](https://forum.babylonjs.com/t/recast-navmesh-floating-agents/11770/8 "2020-06-17T14:34:16Z")

</div>

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

?

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [June 17, 2020, 2:40pm UTC](https://forum.babylonjs.com/t/recast-navmesh-floating-agents/11770/9 "2020-06-17T14:40:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![suredelta](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@suredelta](https://forum.babylonjs.com/u/suredelta)\
**Post date:** [June 17, 2020, 2:46pm UTC](https://forum.babylonjs.com/t/recast-navmesh-floating-agents/11770/10 "2020-06-17T14:46:36Z")

</div>

Thank you Cedric.

---

<div class="post-metadata">

**Author:** ![Jack2](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jack2/32/30179_2.png) [@Jack2](https://forum.babylonjs.com/u/Jack2)\
**Post date:** [April 7, 2023, 4:05am UTC](https://forum.babylonjs.com/t/recast-navmesh-floating-agents/11770/11 "2023-04-07T04:05:56Z")

</div>

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](https://www.youtube.com/watch?v=-xMA2eiJsmk)

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [April 7, 2023, 7:48am UTC](https://forum.babylonjs.com/t/recast-navmesh-floating-agents/11770/12 "2023-04-07T07:48:59Z")

</div>

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](https://doc.babylonjs.com/guidedLearning/createAGame/collisionsTriggers) ) or even physics.  
It all depends on your use-case.

---

<div class="post-metadata">

**Author:** ![yedpodtrzitko](https://avatars.discourse-cdn.com/v4/letter/y/a9a28c/32.png) [@yedpodtrzitko](https://forum.babylonjs.com/u/yedpodtrzitko)\
**Post date:** [May 12, 2025, 9:05pm UTC](https://forum.babylonjs.com/t/recast-navmesh-floating-agents/11770/13 "2025-05-12T21:05:45Z")

</div>

Hi,  
here’s my solution for this problem. It’s probably not an universal solution, but it works for this use-case:

- get the actual agent height via `navmesh.getClosestPoint()`
- calculate the difference between Y of given point and Y of the floor
- move the box by given value.

Updated example: [https://www.babylonjs-playground.com/#8HNY00#2](https://www.babylonjs-playground.com/#8HNY00#2)
