// Update is called once per frame void Update() { npcAnimator.SetFloat(hashSpeed, navMeshAgent.velocity.magnitude); DT_Action dt_NewAction = null; if (!useHardcodedDT) { dt_NewAction = dtNode_Root.MakeDecision() as DT_Action; } else { //TODO: YOUR CODE HERE (Q2) } if (dt_NewAction != null) { if (dt_NewAction != dt_LastAction) { if (dt_LastAction != null) { dt_LastAction.end(); } dt_NewAction.init(); } else { dt_NewAction.update(); } } dt_LastAction = dt_NewAction; //canHearPlayer = false; }
void BuildDecisionTree() { idle = new DT_Action(ActionInit_Idle, ActionUpdate_Idle, ActionEnd_Idle); inspect = new DT_Action(ActionInit_Inspect, ActionUpdate_Inspect, ActionEnd_Inspect); attack = new DT_Action(ActionInit_Attack, ActionUpdate_Attack, ActionEnd_Attack); //TODO: YOUR CODE HERE (Q1) DT_Decision dtNode_InAttackRange = new DT_Decision(IsInAttackRange, attack, inspect); dtNode_Root = new DT_Decision(CanSeePlayer, dtNode_InAttackRange, idle); dt_LastAction = null; }