Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Navmesh Links can't be turned off

Discussion in 'Navigation' started by hippocoder, Jul 6, 2017.

  1. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hi,

    I have an agent and I move it manually while reading the .desiredVelocity to figure out the movement.

    But before setting .destination, I have to hide my navmesh link if I don't want a particular character to use that link. Is this the right way since Auto Traverse Off Mesh Link being unchecked does absolutely NOTHING for manual agent even though I am reading .desiredVelocity - the agent clearly ignores this checkbox in this circumstance.

    All I can do is hide the link before I set the destination - a huge hack?
     
  2. Jakob_Unity

    Jakob_Unity

    Unity Technologies

    Joined:
    Dec 25, 2011
    Posts:
    269
    Yes the 'autoTraverseOffMeshLink' controls the movement behaviour over the link (automatic or not) - it does not decide whether the link is accessible to pathfinding.

    • One way is to disable the link before setting the destination, then enabling it - when the path is found.
    • Another way is to use a specific area-type for the link - then set the agents area mask to exclude that of the link.
    (see also https://docs.unity3d.com/Manual/nav-AreasAndCosts.html)
     
  3. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Thanks Jakob, your advice is great :)
     
  4. iwHiteRabbiT

    iwHiteRabbiT

    Joined:
    Feb 15, 2011
    Posts:
    47
    Maybe it's kind of the same issue/solution, but here is my case:
    - Many closed doors (NavMeshLink) - More than 29...
    - Many agents with different door keys
    - Many agents without any key

    What would be the best solution to achieve that?

    It seems to be a bad idea to enable/disable every NavMeshLink before setting each destination of each agent, isn't it?