Search Unity

Can you manually change the destination of an agent waiting in a link?

Discussion in 'Navigation' started by A_Box, Nov 15, 2021.

  1. A_Box

    A_Box

    Joined:
    Feb 3, 2020
    Posts:
    62
    I have a NavMeshLink with "AutoUpdatePosition" off. The behaviour i want to create i this:
    The agent arrives to the navmeshlink (it goes trough a door).
    If the door is unlocked, then i send the agent to the other side of the door (no issues here).
    If the door is locked, i deactivate the link and recalculate the path, in case there is another path to the destination that doesn't involve traversing the door.

    The problem is that once the the agent is in the link without AutoUpdatePosition, it won't exit the link even after the path is updated into one that requires no link.

    My workaround is that after deactivating the link i save in temporary vector3s the start/end positions of the link, set those position to be the position of the agent, call CompleteOffMeshLink() to let the agent out of the link while remainig it the same position, calculate a new path (the link is still off), and finally i reactivate the link and set it's initial start/end positions values.
    ...But this isn't working.

    Have any idea why? Or even better, is there a way to say to the agent "you are not on the link anymore, you are on the navmeshsurface" instead of having to edit the link's starting/ending points and completing the trasition?

    Thanks for reading
     
  2. N7D

    N7D

    Joined:
    Feb 25, 2017
    Posts:
    9