Updating navmesh and RecastJSCrowd

Hi @Cedric,

New question for you regarding to navigation stuff : )

In Question on RecastJSCrowd's function agentGoto(), 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

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.


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

1 Like