Search Unity

Navmesh Agent - Multiple agents taking the same path?!

Discussion in 'Navigation' started by besieger1, Dec 19, 2014.

  1. besieger1

    besieger1

    Joined:
    Jul 26, 2012
    Posts:
    34
    Hi

    I have a problem with the navmesh agents all following the same path, I know this is intended but how can I make some of the agents take a different path to their target?

    I have 3 agents, Cubes all in the same position, they all take the same path. I want them to take different paths.

    I hope I was clear enough for you guys, Thanks
     
  2. besieger1

    besieger1

    Joined:
    Jul 26, 2012
    Posts:
    34
    Anyone?... Please :(
     
  3. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Why do you want them to take different paths? Is it because they are interpenetrating with one another or for some visual diversity? In the former case, you should use dynamic obstacle avoidance on top of the base nav mesh.
     
  4. besieger1

    besieger1

    Joined:
    Jul 26, 2012
    Posts:
    34
    I am just trying to get more of a visual diversity witch will in turn help make the game a little more challenging and less predictable
     
  5. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    For regular visual variety, nav mesh isn't the best tool, but you can try using different layers with different costs. If the costs are different enough between units, they will take different paths. Otherwise, it's better to do something at the AI level, like different intermediate goals that are guaranteed to follow different paths.
     
  6. CodeElemental

    CodeElemental

    Joined:
    Feb 6, 2014
    Posts:
    15
    I think you can use Avoidancepriority (agents avoid each other while moving). For a more controlled and robust approach you should use dynamic obstacle avoidance as @MakeCodeNow suggested.
     
  7. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    youll have to come up with your own waypoint system if you want them to take a random path.
     
  8. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    Instead of going directly to the destination, make them go through intermediate destination before and randomize them.
    For example, the cubes must go from source A to destination B. Specify in advance intermediate destination C D E F G each on a different path, then each cube will go from A to random (C D E F G) and from there to B.