IEnumerator PerformNormalAttack() { //MovementCtrl.StopMovement(); MovementCtrl.SetSpeed(1f); AI.ChangeStatus(EnemyBehaviorStatus.Attacking); AI.ChangeAction(EnemyActions.NormalAttack); sword.damage = PlayerDamageValues.Instance.NormalAttackDamage; //Animation Section //AI.anim.applyRootMotion = true; //Attack animatin is currently .1 meters higher than normal //AI.anim.transform.position = new Vector3(AI.anim.transform.position.x, AI.anim.transform.position.y - .15f, AI.anim.transform.position.z); int attackIndex = Random.Range(0, 2); //attackIndex = 1;//MARK: UNTIL WE FIX THE ATTACK ANIMATIONS bool interupped = false; if (attackIndex == 0) { AI.anim.Play("RunningAttack"); //AI.anim.transform.localEulerAngles = new Vector3(0, 0, 0); float tempAnimationTime = 2f; float tempAnimationCount = 0; //we need to end prematurely if the enemy is staggered while (tempAnimationCount < tempAnimationTime) { yield return(null); tempAnimationCount += Time.deltaTime; if (AI.GetDirector().IsInterupted(AI.GetCurrentStatus())) { interupped = true; break; } if (tempAnimationCount > 1.1f) { MovementCtrl.SetSpeed(0); } } } else { MovementCtrl.SetSpeed(0); Quaternion savedRot = AI.anim.transform.localRotation; AI.anim.transform.localRotation = Quaternion.Euler(new Vector3(0, 170, 0)); AI.anim.Play("BranchAttack_swing1"); //AI.anim.transform.localEulerAngles = new Vector3(0, 0, 0); float tempAnimationTime = 1.6f; float tempAnimationCount = 0; //we need to end prematurely if the enemy is staggered while (tempAnimationCount < tempAnimationTime) { yield return(null); tempAnimationCount += Time.deltaTime; if (AI.GetDirector().IsInterupted(AI.GetCurrentStatus())) { interupped = true; break; } if (tempAnimationCount > 1.1f) { MovementCtrl.SetSpeed(0); } else { AI.transform.LookAt(playerT.position); } } AI.anim.transform.localRotation = savedRot; } //Sword.SetActive(false);//tempAniamtionFake //Animation Section //AI.anim.applyRootMotion = false; //transform.position = AI.anim.transform.position; //AI.anim.transform.localPosition = new Vector3(0, -1, 0); AI.GetDirector().NormalAttackCompleted(); if (!interupped) { AI.ChangeStatus(EnemyBehaviorStatus.Waiting); AI.anim.Play("Idle"); } AI.ChangeAction(EnemyActions.None); MovementCtrl.RestoreSpeed(); //MovementCtrl.ResumeMovement(); }