Search Unity

Nav Mesh rebuild only a portion of the nav mesh due to terrain changes

Discussion in 'Navigation' started by dhenion65, Jun 6, 2020.

  1. dhenion65

    dhenion65

    Joined:
    Dec 17, 2019
    Posts:
    21
    I've added a way to modify the terrain heights in-game, all is working great - the last piece is to update the nav mesh so that AI's see the new shape of the terrain.

    I tried NavMeshSurface.BuildNavMesh() and it works, but is slow - and doesn't make sense to rebake the mesh for the entire terrain when only a small portion has been modified.

    So I set NavMeshSurface.center and NavMeshSurface.size - which "works" - the area in that volume is updated, but the rest of the nav mesh is then gone.

    Tried breaking it up in to multiple nav mesh surfaces - but would have to add hundreds of nav mesh links to connect them - and the links don't work very well on non-flat surfaces.

    I tried the LocalNavMeshBuilder.cs script from the github examples - it kinda works but creates a second nav mesh on my terrain, which seems to really confuse the nav agent. This solution would be perfect if it just modified the existing nav mesh.

    I tried navMeshSurface.UpdateNavMesh(navMeshSurface.navMeshData) but it doesn't seem to do anything.


    Any suggestions on how to do or what I'm missing? I've been reading through old posts but still can't find how to do. Any help greatly appreciated!
     
  2. dhenion65

    dhenion65

    Joined:
    Dec 17, 2019
    Posts:
    21
    Bump.... Anyone have any ideas for this? Until I can find a solution this feature of the game can't be implemented.
    I've looked a little at 3rd party pathing tools like some of the A* flow path options on the asset store. A* Pathfinding Project Pro seems can do this, but is pretty expensive and a bit daunting to learn a whole new navigation system. Anyone have experience with it or can recommend any other solutions?