Search Unity

Question about pathfinding: navmesh splitting and obstacle avoidance

Discussion in 'Editor & General Support' started by chansey97, Apr 20, 2013.

  1. chansey97

    chansey97

    Joined:
    Sep 21, 2012
    Posts:
    59
    Unity's nav mesh baker is awesome, I have used it to make my game.

    But how to update the navmesh in runtime?

    My game is RTS type, there are a lot of obstacles like:

    Buildings which could be created by player. (Wall need be supported, like Age of Empires)

    Units which could be holded on the ground.(Player press "H" key) This means many untis holded could be a man-wall....

    After looking for sorts of articles, I found the best way which could deal with this kind of obstacle was "navmesh splitting"!

    I found a new feature in unity4 navmesh obstacle, but it seems that the navmesh obstacle could not split navmesh! (It works only as a static navmesh agent.....)

    My first questionis:

    Dos unity support "navmesh splitting" now? or It will be supported in the future?


    My second question is:

    If unity does not support "navmesh splitting", how to workaround it?

    (1) Have the 3rd party "navmesh splitting" solution?
    (2) Using steer behavior to avoid obstacle?
    (For example: use radar to filter objcts and raycast a line from transform.forward to intersect collider. But it seems difficult to deal with dense obstacles like man-wall)


    Thank you

    PS: Navmesh spliting image under attachment.
     

    Attached Files:

    Last edited: Apr 20, 2013
  2. rapidfirestudio

    rapidfirestudio

    Joined:
    Jan 31, 2013
    Posts:
    73
    I don't really understand why you would have to "split" a navmesh. It sounds like you have a navmesh with dynamic obstacles. Unity should handle that no problem. Take a look at the different NavMesh classes like NavMeshObstacle and NavMeshAgent. You get a lot of things for free like pathfinding and obstacle avoidance. Just read up on what's available.
     
  3. chansey97

    chansey97

    Joined:
    Sep 21, 2012
    Posts:
    59
    Unfortunately, the NavMeshObstacle work not very fine from my test....(for example: When meet cluster obstacles)
    In my opinion, the NavMeshObstacle in fact is a "dynamic obstacles" in steering concept, not in pathfinding!
    "dynamic obstacles" is also very important in Game AI, but it is not what I need.
     
  4. GBCFraser

    GBCFraser

    Joined:
    Apr 11, 2013
    Posts:
    94
    The navmesh only works with static scenes. You have to bake the nav mesh before you can run the navmesh agent, you have to bake it when you change static objects in the scene or the objects will move according to the old navmesh. There is a nav mesh obstacle but it only seems to have a cylindrical radius. Its very useful for pathfinding, but it has its limitations. For example, a procedurally generated dungeon at runtime, wouldn't work well with the navmesh. Its also useful for creating favorable paths such as choosing between a river, which slows movement down, and a bridge, which has no penalty. But it sure beats having to come up with pathfinding yourself. You can create a game quicker.
    The buildings could be navmesh obstacles, but the game would see them a circular obstacles.
     
  5. Pangamini

    Pangamini

    Joined:
    Aug 8, 2012
    Posts:
    54
    When i inspect the baked navMesh object, there is an array of human-unreadable data. It's not documented, but invokes an idea that the navMesh might be actually editable in runtime?
     
  6. CptDator

    CptDator

    Joined:
    Jan 19, 2013
    Posts:
    1

    To make NavMeshObstacle modify the NavMesh, you have to check its "Carve" option. You have to be wary of it tough, cause moving NavMeshObstacle with a carve option on is quite taxing on the pathfinding calculation.

    If you are doing an RTS with a spearwall formation, enabling carving might be counter productive because the ennemy will run around your defensive formation and go right into your backline. But for building and wall, that do the trick.