# Updating navmesh and RecastJSCrowd

**URL:** <https://forum.babylonjs.com/t/updating-navmesh-and-recastjscrowd/7232>\
**Category:** Questions\
**Created:** [November 27, 2019, 12:37am UTC](https://forum.babylonjs.com/t/updating-navmesh-and-recastjscrowd/7232 "2019-11-27T00:37:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jieling\_Yang](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jieling_yang/32/2547_2.png) [@Jieling\_Yang](https://forum.babylonjs.com/u/Jieling_Yang)\
**Post date:** [November 27, 2019, 12:37am UTC](https://forum.babylonjs.com/t/updating-navmesh-and-recastjscrowd/7232/1 "2019-11-27T00:37:36Z")

</div>

Hi @Cedric,

New question for you regarding to navigation stuff : )

In [Question on RecastJSCrowd's function agentGoto()](https://forum.babylonjs.com/t/question-on-recastjscrowds-function-agentgoto/7211), I described the scenario of dynamically adding obstacles for crowd. So every time when a new “building” is placed, I call `RecastJSPlugin.createMavMesh()` to update navmesh. It works, but with a brief performance drop. I experimented a bit and found that `cs` of `INavMeshParameters` has a big impact on it, which make sense, smaller cell size, heavier the calculation.

Then after update the navmesh, I need to update the related `RecastJSCrowd` object. I assume calling `RecastJSPlugin.createCrowd()` every time after navmesh gets updated is not the way to go. According to API, `RecastJSCrowd.update()` seems to update only agent position/velocity/acceleration, and I tried to use it but failed anyway.

So, here are my 2 questions:

1. Is calling `RecastJSPlugin.createMavMesh()` the proper way for updating navmesh? If it is, how to handle the performance drop?
2. How to update crowd after navmesh update?

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:** [November 27, 2019, 8:26am UTC](https://forum.babylonjs.com/t/updating-navmesh-and-recastjscrowd/7232/2 "2019-11-27T08:26:39Z")

</div>

Hi !

Yes, createNavMesh is the only way to update the navmesh. Then, best way is to recreate the crowd with the agent positions.  
This is definitely not the way it should be. Dynamic obstacles would solve the issue.  
BTW, maybe you can add a new type of agents, in the same crowd. Agents whose radius corresponds to the obstacles you have and non moving. Basically, use non moving agents as obstacles. With collision avoidance, it might work.

---

<div class="post-metadata">

**Author:** ![Jieling\_Yang](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jieling_yang/32/2547_2.png) [@Jieling\_Yang](https://forum.babylonjs.com/u/Jieling_Yang)\
**Post date:** [November 27, 2019, 9:00am UTC](https://forum.babylonjs.com/t/updating-navmesh-and-recastjscrowd/7232/3 "2019-11-27T09:00:07Z")

</div>

That’s a brilliant idea! Using non-movable agent as obstacle… Thanks man!
