- Home /
How to handle many navmeshes in 1 scene ?
Hi, I used unity2019.3
I do use navMesh and navMeshAgent.
My goal is to change the navmesh on runtime: at begin, player can only walk in small red circle, then after some conditions, he can walk in a big rectangle area (small red circle is inside the big rectangle area)
Is it possible to have 2 navmeshes and then switch them by setActive(bool) ?
Any idea on how to achieve that ?
Answer by Hellium · Jan 08, 2020 at 11:00 AM
You don't need several Navmeshes, a single one with several areas will work.
Then, set the mask on your agent according to your conditions.
agent.areaMask = 1 << index_of_1st_layer |
1 << index_of_2nd_layer |
1 << index_of_3rd_layer;
That looks promising.. but I just cannot find how to edit an area: when baked, it bakes always the WHOLE big rectangle.
How can I add a circle area in a navmesh ?
Create a new area in the
Navigation
window,Create a new Cylinder and place it so that its top surface is very close to the surface of your rectangle
Set it to
Navigation static
In the
Navigation
window, select your new area in theObject
tab (cylinder must be selected)Bake your navmesh (adjust the Voxel size to have a more precise shape around your cylinder)
Disable the Cylinder
Almost done: Just to understand well:
Walkable
Not walkkabe
Jump
bigRectangle
smallCircle
To choose smallCircle only :
agent.area$$anonymous$$ask = 1<< 4
To choose bigRectangle AND smallCircle
agent.area$$anonymous$$ask = 1<< 3 | 1<<4
Is that correct ?