- Home /
Multiple Nav Mesh in same scene?
I have a scene in which I have built 3 areas (they exist in same scene over the top of each other with one active and others deactivated.
I have 3 AI's in the scene using nav mesh to navigate around.
I have trggers set up so that when the player enters the trigger it hides one area and makes another active eg: player enters lava cave trigger > forest area setactive(false) > lava setactive(true)
Is it possible to have different nav meshes for each areas geometry? I was looking at layers but I don't know how I would tell unity to use a specific layer when an area is active, if this is even possible?
What problem are you trying to solve? $$anonymous$$g. what's preventing you from using one Nav$$anonymous$$esh for all three areas?
For example if I am currently in the lava area (has ramps upto platforms etc) then I go to the trigger to load the forest area (activate (disabling the laval level geometry)).
The AI's still seem to be following the lava nav mesh for example walking up invisible ramps, which are not there in the forest scene so they are doing so in mid air.
Are you using Nav$$anonymous$$eshLink to move from one Nav$$anonymous$$esh to another ?
Answer by ahorne · Jul 10, 2017 at 07:04 PM
Yes Yes. This is totally doable.
https://docs.unity3d.com/Manual/NavMesh-BuildingComponents.html https://github.com/Unity-Technologies/NavMeshComponents
I am not sure what you are trying to accomplish though with 3 overlapping navmeshes, only one of which you want active at a time. If you are having different navmeshes for different AgentTypes, they can all actively exist at the same time, you don't need to deactivate all but one. Just keep the AgentTypes different. If you are using NavMeshLink you'll need a link for each AgentType as well.
Good Luck!
ok, let me try and explain what i'm doing:
I had trouble with the third person character & controls setup. When I loaded a new scene by entering a trigger object the new scene would load and the player would just move on it's own with player having no control see: http://answers.unity3d.com/questions/1374747/third-person-controller-and-switching-scenes.html
So to get around this I decided to save each scene into an empty gameobject and have them all in the same scene. So in one scene I have different game objects containing the scenes eg: forest, lava, scifi etc If you are in forest the other gameobject (levels) are deactivated.
I have triggers so that you can walk into a new area, which will deactivate the current gameobject and activate the new one say lava level for instance.
Sooo, if I select the forest area and bake a navmesh everything fine, AI's walk around over ramps etc bump into trees.
then if i deactivate the forest level and activate the lava one and bake the nav mesh that works also but when I activate the forest one again the navmesh is that of the lava level.
I tried setting a different layer for each nav mesh but I dont know how to tell unity to use say layer 3 lava navmesh when lava level is active or layer 1 forest navmesh when forest is active.
sorry if this sounds crazy trying this navmesh stuff for the first time in this game!
Rendering/Physics layers are probably not the way to go here. Are you using Nav$$anonymous$$eshSurfaces or just Nav$$anonymous$$esh and loading multiple scenes? Are you baking Nav$$anonymous$$esh/Surface's at runtime?
I just select the objects and make walkable (or not if tree etc) then bake.
I'm not loading any scenes it's all in the same scene.
On the navigation panel, I have made forest user layer 0, lava user layer 1 and scifi user layer 2 (all cost 1).
I want to be able to say if forest area active, use navmesh layer 1, if lava use navmesh layer 2 etc. (if this is possible).