Search Unity

Any idea's on how to achieve this using Unity's Pathfinder?

Discussion in 'Navigation' started by giraffe1, Aug 13, 2016.

  1. giraffe1

    giraffe1

    Joined:
    Nov 1, 2014
    Posts:
    302
    I was reading about tactical pathfinding in Killzone(page 7) and was wondering if there is any way to achieve similar results using Unity's pathfinder?

    How could I get the AI to choose the path on the right that is out of the sight of the threat?

    Any idea's? Even hacky ones?

    pic.png
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,442
    Maybe could place invisible dynamic obstacles to cover threat zones..so AI is forced to take other route,
    but might end up with no routes at all, then need to keep removing obstacles, until there is way..

    If with unity navmesh can adjust movement cost areas on the fly, then make threat-visible areas very high cost?
    https://docs.unity3d.com/ScriptReference/NavMeshAgent.SetAreaCost.html
     
    laurentlavigne likes this.
  3. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    Another way is casting rays from the enemy outwards to define cover nav points, something similar to what Eric does in Panda BT cover routine : https://www.assetstore.unity3d.com/en/#!/content/33057

    I'd steer clear from unity navmesh until they completely rethink this thing because it's just not designed for AI-on-a-grid (even thought that's what games have been doing for 20 years...)

    But... if you really must use unity navmesh you could have two meshes, one for team A and one for team B, this way you can carve one without affecting the other (@mgear idea).

    SetAreaCost is ok but be ready to go through authoring hell because areas are static: navmesh obstacle can't define an area's shape dynamically the same way they can carve (hey, new navmesh guy, here is a good idea).

    Finally, If you're open to using something else, Astar might work but you'll still have to do the cover casting anyway.
     
    Last edited: Aug 15, 2016
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,442
    Maybe could also just add extra way-points to the path,
    for example, add 10 points between start-end,
    then from each point, check if its inside Threat-area,
    if yes, then move the point into closest safe area or so..
     
  5. giraffe1

    giraffe1

    Joined:
    Nov 1, 2014
    Posts:
    302
    thanks for the great suggestions everyone!