/** * <summary>Change animation according to the state</summary> **/ private void ChangeAnimation() { ChangeSpeedOfAnimation(); if (currentState != State) { string stateString = "Archer_"; switch (State) { case ArcherAnimationStateEnum.Idle: stateString += "Idle"; currentState = ArcherAnimationStateEnum.Idle; break; case ArcherAnimationStateEnum.RunningIdle: stateString += "Idle"; currentState = ArcherAnimationStateEnum.RunningIdle; break; case ArcherAnimationStateEnum.Running: stateString += "Walk"; currentState = ArcherAnimationStateEnum.Running; break; case ArcherAnimationStateEnum.Shooting: stateString += "Attack"; currentState = ArcherAnimationStateEnum.Idle; State = ArcherAnimationStateEnum.Idle; break; } ArcherAnimator.Play(stateString); } }
/** * <summary>Change animation speed for running animation</summary> **/ private void ChangeSpeedOfAnimation() { if (State == ArcherAnimationStateEnum.Running || State == ArcherAnimationStateEnum.RunningIdle) { if (RunningSpeed != 0) { State = ArcherAnimationStateEnum.Running; ArcherAnimator.speed = RunningSpeed; return; } State = ArcherAnimationStateEnum.RunningIdle; } ArcherAnimator.speed = 1f; }