Search Unity

Selecting which NavMesh an agent should use?

Discussion in 'Navigation' started by Sebioff, Mar 12, 2019.

  1. Sebioff

    Sebioff

    Joined:
    Dec 22, 2013
    Posts:
    190
    I have multiple overlapping NavMeshes that are in the same physical location. How do I select which of those NavMeshes an agent should use?
    Unity seems to decide itself which NavMesh to use depending on the location at which the agent object is when the NavMeshAgent component gets enabled, and if there are multiple overlapping NavMeshes at this position it seems to arbitrarily choose one of them based on some hidden internal logic.

    Unity already does keep track of which NavMesh an agent is currently using/being restricted to and exposes that through the NavMeshAgent.navMeshOwner property, but unfortunately that's read-only… surely there has to be some way to decide this ourselves though instead of letting Unity pick one at random?
     
    BrandStone likes this.
  2. BrandStone

    BrandStone

    Joined:
    Jul 21, 2014
    Posts:
    78
    I would also like to know this. I have humans and animals roaming. I would like humans to use roads while animals should ignore the roads.
     
  3. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    469
    Normally you should use multiple NavMeshes if you have multiple agent types.
    That way you simply assign the correct agent type to each agent, and it should pick out the navmesh associated with the agent type.
     
    BrandStone likes this.
  4. Sebioff

    Sebioff

    Joined:
    Dec 22, 2013
    Posts:
    190
    I guess that makes sense. Solves my case, thanks!
     
unityunity