// This is called when the node is updated public override Result OnUpdate(BehaviorTreeExecutor behaviorTreeExecutor) { NavMeshAgent navMeshAgent = behaviorTreeExecutor.GetComponent <NavMeshAgent>(); if (navMeshAgent == null) { UnityEngine.Debug.LogError(behaviorTreeExecutor + " has no nav mesh agent component assigned.", behaviorTreeExecutor); } navMeshAgent.isStopped = true; return(Result.Success); }
// This is called when the node is updated public override Result OnUpdate(BehaviorTreeExecutor behaviorTreeExecutor) { if (agent == null) { agent = behaviorTreeExecutor.GetComponent <NavMeshAgent>(); if (agent == null) { UnityEngine.Debug.LogError(behaviorTreeExecutor.name + " has no NavMeshAgent component assigned but " + name + " is trying to access it.", behaviorTreeExecutor); return(Result.Failure); } } GameObject target = behaviorTreeExecutor.GetGameObjectVariable(targetID); if (target == null) { UnityEngine.Debug.LogError("Did not find target object with id " + targetID + " for " + GetType(), behaviorTreeExecutor); return(Result.Failure); } agent.SetDestination(target.transform.position); return(Result.Success); }