2d physics

Hello, I’m making a platform game endless runner. I have a car on the platform using real physics and a rigidybody but as ilistra the image, I’m not getting the second image effect, my car is going backwards. Can anyone help me make the car ride only forward!

29499-untitled-2.jpg

One way to do this would be to constrain the x value on your velocity.

void FixedUpdate(){
    float xSpeed = rigidbody2D.velocity.x;
    xSpeed = Mathf.Clamp (xSpeed, 0, Mathf.infinity);
    rigidbody2D.velocity = new Vector2 (xSpeed, rigidbody2D.velocity.y)
}

This will result in strange physics though. A better way would be to simply add sufficient force so that the car can overcome any ramps in its path.