private void GetInput() { if (_controller.isGrounded) { _velocity.y = 0; } if (player.GetActionState() != PlayerActionState.DODGING) { if (player.GetMoveRight()) { normalizedHorizontalSpeed = 1; } else if (player.GetMoveLeft()) { normalizedHorizontalSpeed = -1; } else { normalizedHorizontalSpeed = 0; } // we can only jump whilst grounded if (_controller.isGrounded && player.GetJump()) { _velocity.y = Mathf.Sqrt(2f * player.jumpHeight * -player.gravity); } } if (player.GetAttack() && !player.GetDodge()) { player.SetActionState(PlayerActionState.ATTACKING); } else if (player.GetDodge()) { player.SetActionState(PlayerActionState.DODGING); if (player.role != PlayerClass.KNIGHT) { if (player.aim.GetFacingRight()) { dodgeDirection = DIRECTION.LEFT; normalizedHorizontalSpeed = -1; } else { dodgeDirection = DIRECTION.RIGHT; normalizedHorizontalSpeed = 1; } _velocity.y = Mathf.Sqrt(2f * player.jumpHeight * -player.gravity); } else if (player.role == PlayerClass.KNIGHT) { dodgeDirection = DIRECTION.NONE; normalizedHorizontalSpeed = 0; } } else { player.SetActionState(PlayerActionState.NULL); } if (player.GetSlide() && player.GetMoveState() != PlayerMoveState.MIDAIR && player.GetActionState() != PlayerActionState.DODGING) { player.SetMoveState(PlayerMoveState.SLIDING); normalizedHorizontalSpeed = -0.5f; } else if (!_controller.isGrounded) { player.SetMoveState(PlayerMoveState.MIDAIR); } else { player.SetMoveState(PlayerMoveState.RUNNING); } }