How to move rigidbody a certain distance, rather than constantly

rb2d.MovePosition(rb2D.position + velocity * Time.fixedDeltaTime);

will move the player constantly. However, I would like the player to move a certain distance in a certain direction when the left arrow key is pressed, as if they have teleported to the new position. I can do it with transform.translate, but this means it won’t work with collisions. Any idea how I can do this with Rigidbody2d.MovePosition? ?

I have tried:

if (Input.GetKeyDown(KeyCode.LeftArrow))
{
rb2D.MovePosition(rb2D.position + velocity * Time.fixedDeltaTime); 
}

But that doesn’t result in movement

Thanks!

Drop the Time.fixedDeltaTime, that is interpolating the distance between the frames so it moves smooth,ly however, for you case, you don’t need it. See if that works :slight_smile:

(Edit) Here :

 if (Input.GetKeyDown(KeyCode.LeftArrow))
 {
 rb2D.MovePosition(rb2D.position + velocity); 
 }