// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (fAI == null) { fAI = animator.GetComponent <FarmerAI>(); } currTarget = fAI.CurrTarget.GetComponent <TreeControl>(); timer = 0f; currTarget.StartCutting(); currTarget.CurrentHealth -= 1; //subtract 1 health immediately after cutting started to avoid delay related situations }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (navAgent == null) { navAgent = animator.GetComponent <NavMeshAgent>(); } if (fAI == null) { fAI = animator.GetComponent <FarmerAI>(); } navAgent.speed += speedIncrease; FindFleeDestination(animator); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (fAI == null) { fAI = animator.GetComponent <FarmerAI>(); } if (navAgent == null) { navAgent = animator.GetComponent <NavMeshAgent>(); } navAgent.enabled = true; timer = 0f; }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (navAgent == null) { navAgent = animator.GetComponent <NavMeshAgent>(); } if (fAI == null) { fAI = animator.GetComponent <FarmerAI>(); } //set the navmesh agent target currTarget = fAI.CurrTarget; navAgent.SetDestination(currTarget.transform.position); }