using UnityEngine; // ReSharper disable once CheckNamespace namespace BlueWaterProject { public class Dash : StateMachineBehaviour { private CombatPlayer combatPlayer; public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (combatPlayer == null) { combatPlayer = animator.GetComponentInParent(); } combatPlayer.IsDashing = true; combatPlayer.EnableDash = false; } public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { combatPlayer.Rb.velocity = combatPlayer.PreviousDir * combatPlayer.DashForce; if (stateInfo.normalizedTime >= 1.0f) { animator.SetBool(combatPlayer.isDashingHash, false); } } public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { combatPlayer.IsDashing = false; animator.SetBool(combatPlayer.isDashingHash, false); combatPlayer.CoolDown(combatPlayer.DashCooldown, () => combatPlayer.EnableDash = true); } } }