# Moving imported navmesh

**URL:** <https://forum.babylonjs.com/t/moving-imported-navmesh/57102>\
**Category:** Questions\
**Tags:** navigation\
**Created:** [March 13, 2025, 9:56am UTC](https://forum.babylonjs.com/t/moving-imported-navmesh/57102 "2025-03-13T09:56:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![3D-Bear](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/3d-bear/32/30659_2.png) [@3D-Bear](https://forum.babylonjs.com/u/3D-Bear)\
**Post date:** [March 13, 2025, 9:56am UTC](https://forum.babylonjs.com/t/moving-imported-navmesh/57102/1 "2025-03-13T09:56:01Z")

</div>

Hi all,

I am currently working on a project featuring a large square map which is a grid made of 5x5 cells. The goal is to select one of the cells to make an avatar spawn in it and make it able to navigate inside the cell with a navmesh.

For performance reasons, I’d like to keep separate navmeshes (one for each cell) and only load the one corresponding to the cell once it has been chosen (I made all navmeshes in blender and baked them with the great [babylon.js NavMesh Editor](https://navmesh-editor.babylonjs.xyz/)).

The issue I am facing is that by default all navmeshes load at coordinates (0,0) of my grid, so they do not correspond with the cell’s location in the scene.

The only way I found to make them load “in” the cell, is to include the needed offset directly from the modelling step in Blender. Although it is working, I find it kind of unconvenient.

Is there another simpler solution that I missed to “move” the navmesh once it has been loaded ?

Thank you ! 🙂

---

<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:** [March 13, 2025, 2:29pm UTC](https://forum.babylonjs.com/t/moving-imported-navmesh/57102/2 "2025-03-13T14:29:38Z")

</div>

I quickly checked and did not see anything related to an offset for navmesh.  
It looks possible to provide an origin when initializing tiles but I’ve never tested it.  
How big is each cell navigation mesh data? Maybe you don’t need to split?  
If cell are independent, you can do a conversion of space between rendering and navigation.  
Navmesh stays at 0,0,0 but you add/remove offset when converting from a path to the corresponding rendering world position.

cc @roland

---

<div class="post-metadata">

**Author:** ![3D-Bear](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/3d-bear/32/30659_2.png) [@3D-Bear](https://forum.babylonjs.com/u/3D-Bear)\
**Post date:** [March 13, 2025, 2:37pm UTC](https://forum.babylonjs.com/t/moving-imported-navmesh/57102/3 "2025-03-13T14:37:31Z")

</div>

Thank you for having a look at it.  
Each cell is 40x40 meters, the whole grid is supposed to represent a small city. The number of cells may increase in further versions, that is why I thought splitting would be nice for performance.

Converting coordinates is an interesting idea, I will probably go for that if there is nothing more “built-in”.  
Thank you for the suggestion ! 🙂

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [March 13, 2025, 9:07pm UTC](https://forum.babylonjs.com/t/moving-imported-navmesh/57102/4 "2025-03-13T21:07:46Z")

</div>

I can add an `XYZ` input (defaults to `0, 0, 0`) which will offset the vertices of the navmesh when the data are baked if it helps.

---

<div class="post-metadata">

**Author:** ![3D-Bear](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/3d-bear/32/30659_2.png) [@3D-Bear](https://forum.babylonjs.com/u/3D-Bear)\
**Post date:** [March 13, 2025, 10:35pm UTC](https://forum.babylonjs.com/t/moving-imported-navmesh/57102/5 "2025-03-13T22:35:05Z")

</div>

I think that it would be an elegant solution, thank you!

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [March 18, 2025, 7:27am UTC](https://forum.babylonjs.com/t/moving-imported-navmesh/57102/6 "2025-03-18T07:27:56Z")

</div>

[https://navmesh-generator.babylonjs.xyz/](https://navmesh-generator.babylonjs.xyz/) - this is a different link from the one you used to use

I put together a quick solution, but I haven’t had time to test it thoroughly, so I can’t guarantee that it will work without any flaws. Feel free to try it out and let me know if you run into any issues. I’d love to refine it, but I have a lot on my plate at work right now.

The offset will be applied to the exported data only, so you won’t see any changes on the screen:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/4/4/44c5f2d494751eae9547c3a0f5c3af99e8a1f2f5.jpeg)

---

<div class="post-metadata">

**Author:** ![3D-Bear](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/3d-bear/32/30659_2.png) [@3D-Bear](https://forum.babylonjs.com/u/3D-Bear)\
**Post date:** [March 18, 2025, 9:41am UTC](https://forum.babylonjs.com/t/moving-imported-navmesh/57102/7 "2025-03-18T09:41:25Z")

</div>

Thank you ! I will have a look at it and tell you if I get any problems.

I also thought about another approach. Would it be possible to provide the x,y,z offset at import time ? (for example in the `buildFromNavmeshData(...)` function, along with the navmesh data itself.

It would allow to store all the offsets in a config file, apply them at runtime, and easily modify them if needed. This would also make navmeshes reusable in different contexts.

---

<div class="post-metadata">

**Author:** ![3D-Bear](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/3d-bear/32/30659_2.png) [@3D-Bear](https://forum.babylonjs.com/u/3D-Bear)\
**Post date:** [March 18, 2025, 10:31am UTC](https://forum.babylonjs.com/t/moving-imported-navmesh/57102/8 "2025-03-18T10:31:55Z")

</div>

I have done some testing and it seems that the offset is not taken into account.

I get the same results with an offset (I tried different x,y,z combinations) and without it (left at 0,0,0). The result is the same as in the other version of the navmesh editor, navmesh coordinates are relative to the origin of the scene, with no offset.

I know it requires some time to fix this, so let me know if can I help you with some other tests.  
In any case, thank you for your time ! 🙏

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [March 18, 2025, 8:50pm UTC](https://forum.babylonjs.com/t/moving-imported-navmesh/57102/9 "2025-03-18T20:50:40Z")

</div>

> [@3D-Bear](#):
>
> that the offset is not taken into account.

Ooops… I looked at the vertex positions in the dev console and the offset was applied correctly. Maybe there is some issue with the export function. I’ll have a look at it this weekend, do some proper tests and I’m planning to finish the RecastJSNavigationPlugin (@cedric) as well.
