// 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) { // //} // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { // animator.gameObject.GetComponent<EnemyAI>().SamplePatroll(); EnemyAI enemyAI = animator.gameObject.GetComponent <EnemyAI>(); enemyAI.CheckTargetStillVisible(); enemyAI.CheckMeleeAttack(); float speed = enemyAI.movement.speed + 3; if (enemyAI.CheckForObstacle(speed)) { enemyAI.Flip(); enemyAI.ForgetTarget(); } else { enemyAI.SetHorizontalSpeed(speed); } }