(2D) MovePosition slows falling

private void FixedUpdate()
{
rb.MovePosition(rb.transform.position + Vector3.right * runSpeed * Time.fixedDeltaTime);
if (Input.GetButtonDown(“Jump”))
{
RaycastHit2D hit = Physics2D.Raycast(rb.transform.position, Vector2.down, jumpSensitivity);
if (hit == true)
rb.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);
}
}
This is my code. When my script is on, my character moves to the right at the appropriate speed. However, he falls too slowly (he spawns midair). I placed a cube next to him to test the falling speed, and he takes several times longer. When my script is off, however, they fall and hit the ground at the same time.

Anybody know what’s causing this? Thanks!

I believe both the cube and the character have dynamic rigidbody with the same gravity and that’s why you’re surprised of the character falling slower than the cube.

Since you’re using rigidbody.MovePosition you disrupt the ability of the accelerated velocity by the gravity.

If you’ll run a little test you’ll see your rigidbody.velocity is set to 0.

I think you’ll have to add extra velocity calculation by the gravity on your own and add it to your target position for the MovePosition.

I do hope there’s a better way to do it, but not that i know of.

Hope this helps.