Search Unity

When setup SetDestination() and other method.

Discussion in 'Navigation' started by IndieFist, Apr 5, 2020.

  1. IndieFist

    IndieFist

    Joined:
    Jul 18, 2013
    Posts:
    520
    Hi!
    I was searching in a documentation for the best way on how to setup correctly the AI of my enemy.
    The only i have found is, you must change SetDestination in LateUpdate, because when i try it in a earlier frame isn´t working correctly.
    --edit
    When i read that:
    https://docs.unity3d.com/ScriptReference/AI.NavMeshAgent.SetDestination.html

    Maybe when i want to get my enemy goind to other point, should i do that:
    -> agent.stop -> agent.SetDestination() :
    when path is completed if when patrol done? or when is calculated new destination?

    1. Code (CSharp):
      1. if (!NavMeshAgent.pathPending && !NavMeshAgent.hasPath) {
      2.             Debug.Log ("I have reached my destination!");

    Is there any part of documentation that i have mistake?

    Regards,
     
    Last edited: Apr 5, 2020