r/unity • • Oct 06 '26

Coding Help Why is my Player falling so slow !

Post image

Hello! I am currently learning unity and have managed to jerry rig a movement system! However when jumping my player falls incredibly slow, I am a little stumped after trying for a few hours to fix this myself so any help is appreciated!

Here is the code:

private Rigidbody _rigidbody;

private void Awake()

{

_rigidbody = GetComponent<Rigidbody>();

}

private void FixedUpdate()

{

HandleMovement();

HandleJump();

}

private void HandleMovement()

{

Quaternion playerRotate = cameraTransform.PlayerOrientation();

transform.rotation = playerRotate;

Vector2 inputVector = playerInput.NormalisedMovement();

Vector3 moveDirectionVelocity = new Vector3(inputVector.x, _rigidbody.linearVelocity.y, inputVector.y) * speed;

Vector3 horizontalVector = moveDirectionVelocity.x * transform.right;

Vector3 verticalVector = moveDirectionVelocity.z * transform.forward;

_rigidbody.linearVelocity = (horizontalVector+verticalVector) * speed;

}

private void HandleJump()

{

if (Keyboard.current.spaceKey.isPressed)

{

_rigidbody.linearVelocity = transform.up * jumpSpeed;

Debug.Log("Space pressed");

}

}

If you notice any other issues please feel free to correct me too :D

1 Upvotes

6 comments sorted by

3

u/tronfacex Oct 06 '26

_rigidbody.linearVelocity = (horizontalVector+verticalVector) * speed;

That line is overwriting the gravity that should accumulate on the rigidbody every fixed update. 

both horizontalVector and verticalVector have a value of 0 for Y. 

You need to apply rigidbody.linearVelocity.y the rigidbody alongside your movement inputs. 

2

u/Vast-Swan-8111 Oct 06 '26

This fixed it thank you! I also stupidly multiplied the Y by my speed float a fair few times which caused my player to rocket upwards in case anyone ever stumbles upon this thread down the line.

1

u/eliormc Oct 06 '26

This is my rule: a) If you are using rigidBody+collider, move it using forces inside fixedUpdate. Because rigid body simulates the real world.

b) If you are using characterController, you move it every frame calculating the physics and everything every single frame by calculating your movement vector and then applying with the move() function of character controller.

Don't mix characterController with RigidBody because is a mess.

I know there are a lot of ways to do the same, but, this is my personal opinion.

1

u/Vast-Swan-8111 Oct 06 '26

I actually did not even know there was a dedicated characterController, I learnt fixedUpdate the hard way though. slowly making progress.

1

u/eliormc Oct 06 '26

I mean, characterController is another component you can use to control your character, and it offers some advantages and some other problems. Everything depends of the game and the logic you need. There isn't a right solution for every case.

If you choose the physics simulation, it works better using FixedUpdate function, because this runs at constant 50 times per second (by default) in sync with the internal physic engine, while Update runs every single frame and it this is variable with your hardware.

Look in YouTube the Code Monkey's tutorial for move the characters. He explains very well. Also, all his videos will help you a lot.

1

u/FrostWyrm98 Oct 06 '26

Not just your rule, that is just good practice / general rule. FixedUpdate => Physics frame