// Attack the player when this is called private IEnumerator Attack(){ anim = GetComponent<Animator> (); bool killed = false; yield return new WaitForSeconds (.1f); if ((target.position - transform.position).magnitude < damageRange) { // Double check the range before attacking Cutscene cutscene = player.GetComponent<Cutscene>(); cutscene.Attacked (); currentState = "idle"; killed = true; alive = false; agent.speed = 0; } yield return new WaitForSeconds (2.03f); if (killed) { anim.SetTrigger ("isIdle"); SetState ("idle"); }else{ anim.SetTrigger ("is" + currentState.Substring (0, 1).ToUpper () + currentState.Substring (1, currentState.Length-1)); // If it didnt kill return to old anim } attacking = false;