Search Unity

Nav Mesh Agent destination is not being set immediately

Discussion in 'Navigation' started by tanmaykulkarni, Sep 12, 2021.

  1. tanmaykulkarni

    tanmaykulkarni

    Joined:
    Nov 5, 2019
    Posts:
    104
    Hey dudes, I am trying to navigate an agent to a point using NavMesh. Here, when I call
    agent.SetDestination(target.position);

    It set's its destination after a couple of random seconds. And sometimes this line also doesn't work. This delay is something very strange and I don't know why it's happening. Is this a bug or what? Does anyone know any solution? Pls, let me know!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    Is that because it is still computing the path to get there? How are you actually timing this? Obviously agents also have a speed-up and slow-down transition as well...
     
  3. tanmaykulkarni

    tanmaykulkarni

    Joined:
    Nov 5, 2019
    Posts:
    104
    But when I call SetDestination() on another agent, it instantaneously sets its destination and starts moving towards it. Only this agent takes a weird delay!
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    Check its direction: I know if an agent is facing the wrong way and is constrained, it won't start moving backwards. It will spin around fully before it starts moving.

    Alternately, as an example to the other agents, have you considered deleting this agent and telling the others that you'll do that to them if they try anything funny? Development by fear.
     
  5. tanmaykulkarni

    tanmaykulkarni

    Joined:
    Nov 5, 2019
    Posts:
    104
    No, the destination is in front only!
     
  6. tanmaykulkarni

    tanmaykulkarni

    Joined:
    Nov 5, 2019
    Posts:
    104
    Does anybody know any solution?
     
  7. tanmaykulkarni

    tanmaykulkarni

    Joined:
    Nov 5, 2019
    Posts:
    104
    Anyone from Unity Technologies?