virtual protected void Update() { if (IsPlayer & GetComponentInChildren <HP>() != null) { Destroy(GetComponentInChildren <HP>().gameObject); } #region Set Direction if (Rigid.velocity.x > 0.1) { Direction = Directions.Right; } else if (Rigid.velocity.x < -0.1) { Direction = Directions.Left; } if (Direction == Directions.Left) { var scale = transform.localScale; if (SpriteDirection == Directions.Left) { scale.x = 1; } else { scale.x = -1; } transform.localScale = scale; } else { var scale = transform.localScale; if (SpriteDirection == Directions.Left) { scale.x = -1; } else { scale.x = 1; } transform.localScale = scale; } #endregion #region Set Attack State if (!Anim.GetCurrentAnimatorStateInfo(0).IsName("Idle") && !Anim.GetCurrentAnimatorStateInfo(0).IsName("Fly")) { Attacking = true; } else { Attacking = false; } Anim.SetBool("Attacking", Attacking); #endregion #region Attack Time if (!Anim.GetCurrentAnimatorStateInfo(0).IsName("Idle") & !Anim.GetCurrentAnimatorStateInfo(0).IsName("Fly")) { Rigid.velocity = Vector2.zero; if (!AttackBox.gameObject.activeInHierarchy) { AttackBox.gameObject.SetActive(true); } if (Anim.GetCurrentAnimatorStateInfo(0).IsName("Attack")) { AttackBox.GetComponent <BoxCollider2D>().offset = AttackOffset; AttackBox.GetComponent <BoxCollider2D>().size = AttackSize; } else { AttackBox.GetComponent <BoxCollider2D>().size = new Vector2(0.1f, 0.1f); AttackBox.GetComponent <BoxCollider2D>().offset = new Vector2(0, 0); } } else { if (AttackBox.gameObject.activeInHierarchy) { AttackBox.gameObject.SetActive(false); AttackBox.GetComponent <Damage>().Attacked = false; } } #endregion if (Active) { if (Control.GetType() == typeof(PlayerControl)) { ((PlayerControl)Control).InputControl(8, this); } if (Control.GetType() == typeof(AIControl)) { Control.AttackMove("Normal", this); } } Anim.SetBool("Grounded", IsGrounded); }