void FixedUpdate() { if (isJumping) { FixedUpdateJump(); if (!isSurfing) { if (Random.Range(0, 20) < 15) { m_Animations.Play(PlayerAnimation.PlayerStates.Jump); } else { m_Animations.Play(PlayerAnimation.PlayerStates.Jump2); } } else { m_Animations.Play(PlayerAnimation.PlayerStates.Jump); } //Debug.Log("Jumping"); isJumping = false; } if (isFallingDown) { ChangeGravity(); DownForce(); isFallingDown = false; } }
void PlayWalkAnimation(Vector2 velocity) { if (Mathf.Abs(velocity.x) > 0) { _playerAnimation.Play("SideWalk"); } else if (velocity.y > 0) { _playerAnimation.Play("UpwardWalk"); } else if (velocity.y < 0) { _playerAnimation.Play("DownwardWalk"); } else { _playerAnimation.Play("Idle"); } }
void KeyDownAction(KeyCode key) { switch (key) { case KeyCode.A: case KeyCode.D: playerAnimation.Play("IsRun", true); break; case KeyCode.Space: playerAnimation.Play("IsJump", true); if (isGrounded) { playerJump.Jump(jumpPower); } break; case KeyCode.F: int dir = direction.Direction == EDirection.LEFT ? -1 : 1; playerFlash.FlashMove(dir, moveSpeed); break; } }