Unity Rigidbody gravity bugging out over the use of AddForce()

Hello. I wrote a classed called “MovementManager”, and in there, it has a bunch of methods on moving the player. One is called “handleUserInput(Rigidbody rb, float mouseSpeed, float movementSpeed)” and does as the name implies. It works perfectly, but when I call on this method, it causes the rigidbody to not fall, but if i disable the use of this method, it falls.
Any ideas?

Here’s the code;

public static void handlePlayerInputs(Rigidbody player, float mouseSensitivity, float movementSpeed) {
        //Handle Mouse X Rotation of Player\\
        float RotLeftRight = Input.GetAxis("Mouse X") * mouseSensitivity * 50 * Time.deltaTime;

        player.transform.Rotate(0, RotLeftRight, 0);
        //Move Player Forward at a Constant Speed\\
        player.AddForce((player.transform.forward * Time.deltaTime * movementSpeed * 100) - player.velocity, ForceMode.VelocityChange);

        //Handle Jumping\\
        if (Input.GetKeyDown(InputManager.getJumpKey())) {
            player.AddForce((player.transform.up * Time.deltaTime * movementSpeed * 100) - player.velocity, ForceMode.VelocityChange);
        }
    }

I ran your script. The problem you are having with gravity seems to be because you are using ForceMode.VelocityChange for the forward movement. Because it is continuous and not instantaneous it would be better to use ForceMode.Force or ForceMode.Acceleration.

For jumping you would want to use ForceMode.VelocityChange or Forcemode.Impulse, because it is an instant change.

This worked fine for me, but I sucked at your game:

//Move Player Forward at a Constant Speed\\
player.AddForce((player.transform.forward * Time.deltaTime * movementSpeed * 100) - player.velocity, ForceMode.Force);

//Handle Jumping\\
if (Input.GetKeyDown(KeyCode.Space)) 
{
player.AddForce((player.transform.up * Time.deltaTime * movementSpeed * 100) - player.velocity, ForceMode.VelocityChange);
}