- Home /
Physics based movement (Moving to fast)
Good day to you, I LOVE my character controller and its movement. My only issue is that when I move in a certain direction in the air I go WAY too fast, if I slow down the movement I don't have the desired acceleration, but the way it is now my character bolts across the screen. I've tried using else if {(Mathf.Abs(rb.velocity.x) < movement speed)
but if I do so my character snaps really awkwardly when changing direction. I've tried a couple of solutions but none of them work. Any help would be greatly appreciated, thanks in advance.
Here's all the movement scripting I have...
private void ApplyMovement()
{
if (!isGrounded && !isWallSliding && movementInputDirection != 0 && !TransitionAir)
{
Vector2 forceToAdd = new Vector2(movementForceInAir * movementInputDirection, 0);
rb.AddForce(forceToAdd);
}
else if (isGrounded)
{
TransitionAir = false;
rb.velocity = new Vector2(movementSpeed * movementInputDirection, rb.velocity.y);
}
if (isWallSliding)
{
if(rb.velocity.y < -wallSlideSpeed)
{
rb.velocity = new Vector2(rb.velocity.x, -wallSlideSpeed);
}
}
}
Answer by logicandchaos · Feb 23, 2021 at 01:47 PM
multiply your speed my Time.deltaTime, it will also keep your speed consistent. You can also adjust the mass and drag of objects in the editor to get it to move the way you want.