- Home /
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!
How heavy did you make your car? Unless you're going at proper speeds a ramp like that will cause the car to fall backwards, or if you don't have proper gravity for some reason. What do you mean by real physics?
Is 1 , but I put heavier and did not work. I want to make the car go up even when the road is very steep
Perhaps you'd rather have the car follow a set path? There are tutorials around the net that can help with that option.
Yes, it is like rollercoaster but with obstacles, where the car would have to jump across the track. There will be broken rails, so do not know if it would be a good option.
Answer by Kiwasi · Jul 23, 2014 at 02:22 AM
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.
Your answer
Follow this Question
Related Questions
2D 360 degress platformer example needed 0 Answers
Should 2.5D use 3D or 2D settings ? 3 Answers
My character moves in seemingly random directions. 1 Answer
Scale object, collision not working 2 Answers