ExRosbif
ExRosbif

Reputation: 1

Unity AI.Navigation NaveMeshSurface.BuildNavMesh() produces bad results

I am using the AI.Navigation system on the following scene : before play mode

Since it's a scene with element which will be deleted dynamically, I'm not baking the scene beforehand but call once Floor.GetComponent().BuildNavMesh();

"Floor", beeing the game object holding the NavMeshSuface component. The first call does a pretty good job (Except for some reason it exclude the player with the NavMeshAgent, although the player also has a NavMeshModifier component with remove, why ?). first call to BuildNavMesh() in Play mode

Then the next time Floor.GetComponent().BuildNavMesh(); gets called, is when the the game object on the left (the dumpster/garbage) is set to inactive. And then the results is completly wrong : enter image description here

What am I not understanding, doing wrong ? I would like to be able to create a dynamic mesh at runtime which will adapt to active/inactive objects preset with NavMeshModifiers (add/remove). For example, if the dumpster blocks a path, setting it to inactive should "open the path".

I've followed all tutorials I could find, but still can't understand what I am doing wrong.

Thanks

Upvotes: 0

Views: 127

Answers (0)

Related Questions