Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity Pathfinding

Discussion in 'Scripting' started by rocket3000, Sep 4, 2012.

  1. rocket3000

    rocket3000

    Joined:
    Feb 21, 2012
    Posts:
    13
    Hi,
    Im using the unity pro path finding, I know how to make agent go to a destiantion (GetComponent<NavMeshAgent>().destination = new Vector3 ()etc.... but what i cant seem to get right is how to make him do an action when he reaches that destination or how to check when hes reached destination. Any help apreciated thanks..
     
    Last edited: Sep 5, 2012
  2. RazorCut

    RazorCut

    Joined:
    May 7, 2009
    Posts:
    393
    You could just check his distance from his destination and once it is under some threshold do your action. Probably even better to check the nav mesh agent velocity square magnitude and see if that is under some threshold.
     
    Last edited: Sep 5, 2012
  3. RazorCut

    RazorCut

    Joined:
    May 7, 2009
    Posts:
    393
    Actually, looks like "http://docs.unity3d.com/Documentation/ScriptReference/NavMeshAgent-remainingDistance.html" is the way to go.