Search Unity

Runtime area changes?

Discussion in 'Navigation' started by TSabos, Sep 11, 2017.

  1. TSabos

    TSabos

    Joined:
    Mar 8, 2015
    Posts:
    94
    Say you have a street that during normal daytime hours is a typical area weight of 5 for default.

    Once night falls some AI agents would need to adjust the weight to 7 but perhaps some thieves would drop it to 3, or perhaps some guards would want to drop it down to 1 to make that a high priority patrol area.

    Another higher complexity situation is if a street light goes out it would make a "blob" area weight just in a small piece of the mesh.

    Is at least the first piece of this possible, and if so how? Is the 2nd?

    Thanks in advance.
     
  2. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558
    Yes to both. With the navmeshModifier.cs or nav MeshModifierVolume.cs. You can enable those when you need to and trigger your Nav mesh surface to rebuild. I'm hoping the Unity devs could make it a little more runtime friendly, say with a carve option like obstacles so that the nav mesh surface picks up on changes or movement of the modifiers.
     
  3. TSabos

    TSabos

    Joined:
    Mar 8, 2015
    Posts:
    94
    I'm running some tests on the drop_plank scene and it doesn't seem that NavMeshModifier is applied at all when NavMeshBuilder is being called.

    It's doing a good enough job stitching "new" areas together, but how do you enable a mesh with an override area Modifier so that it can be used in the recalculation of the nav area?

    https://www.dropbox.com/s/q89sxxb8v759z6c/2017-09-11_11-59-11.gif?dl=0

    In the above, I'm expecting the NavMeshModifier to be recalculated, but all it's doing is taking the mesh into account when building the total area.

    How do you trigger the NavMeshSurface to rebuild? That seems very convoluted vs using the LocalNavMeshBuilder.
     
    Last edited: Sep 11, 2017
  4. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558
    You can call the method BuildNavMesh on the nav mesh surface. The is also removeData and addData. I'm not sure which is best. Also double check the settings within the navmeshSurface.vs and modifierVolume to make sure it is including them all (I.e. Children, Volume or All).


     
    Last edited: Sep 11, 2017
    TSabos likes this.
  5. TSabos

    TSabos

    Joined:
    Mar 8, 2015
    Posts:
    94
    I tried to follow the bouncing ball from the NavMeshSurfaceEditor to create an async op and have managed to re-create it at runtime.. I think, lol.

    I didn't even see the BuildNavMesh method for at least quick testing. Thanks man.