Search Unity

NavAgents Do not AutoTraverse Occupied Off-Mesh-Links [HELP]

Discussion in 'Navigation' started by DetaPlayFounder, Jun 16, 2022.

  1. DetaPlayFounder

    DetaPlayFounder

    Joined:
    May 10, 2022
    Posts:
    14
    I need Multiple Agents to AutoTraverse a single Link.

    However, the agents wait their turn until the Link is not occupied. Any suggestions on how to Disable this ridiculous behavior?
     
  2. DetaPlayFounder

    DetaPlayFounder

    Joined:
    May 10, 2022
    Posts:
    14
  3. DetaPlayFounder

    DetaPlayFounder

    Joined:
    May 10, 2022
    Posts:
    14
    The question was never answered, although a wasteful work around has been made.

    Is there any official way to Enable more than 1 agent to auto traverse an occupied off mesh link?
     
  4. Legulysse

    Legulysse

    Joined:
    Sep 21, 2013
    Posts:
    1
    I've had the same problem and ended up implementing my own traversal code, allowing multiple agents to traverse the link and making them use their normal speed.
    It seems like there is no way to configure those things in the API and have this behavior without special code.

    The main entry points to implement a custom traversal were :
    - NavMeshAgent.isOnOffMeshLink will be true when the agent is about to traverse the link.
    - NavMeshAgent.currentOffMeshLinkData will contain start/end positions of the link.
    - NavMeshAgent.Warp on its current position will "teleport" the agent, reset its pathfind, and free the link for other agents.
    - .... traversal code (lerp or any other method)...
    - NavMeshAgent.Warp at link destination to ensure it is back on the navmesh.
    - NavMeshAgent.SetPath() to restore the original path (use a backup from before the traversal.

    With this and some adjustments in the character code to disable pathfind requests or any other moves during traversal of the link, I could have something pretty smooth.
     
  5. DetaPlayFounder

    DetaPlayFounder

    Joined:
    May 10, 2022
    Posts:
    14
    Thank you for your reply and solution.

    My solution was to duplicate the off mesh link and have a script for the Agent to detect the link. Once on the link, the script disables the link.

    With the duplicates in place, Agents will avoid Disabled.