Player Movement Issue? Sliding when moving right & back.

Hey guys, getting a little bit of an issue with my player movement. It seems that whenever I move my character to the right or backwards, my player seems to slide. Even if it stop pressing buttons, it keeps moving. I am assuming it has something to do partially with the relation to the camera, but not too sure how to go about fixing it.

Here is the code handling the movement calculations:

void HandleMovement()
{ 
     movementDirection = (cameraObject.right * movementInput[0]) + (cameraObject.forward * movementInput[1]); 
     movementDirection.Normalize(); 
     //movementDirection.y = 0f; 
     //Note that movementVelocity = movementDirection * respective scalar (handled within state machine) 
     characterController.Move(movementVelocity * Time.deltaTime);
}

Here is a video link to what is happening: regallargebluemorphobutterfly

It seems extremely unlikely you want to be normalizing movement because then even the tiniest controller or input drift would give you full movement.

Print out the values you’re feeding into Move() and ensure they truly are zero.

Perhaps if you must normalize, only do so if the magnitude is above a certain amount (such as 0.1f), otherwise clamp motion to zero.

Also, that’s not quite the right formatting for code posting BTW.

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: Using code tags properly

1 Like