# How to move a car around an environment with hills in C++? [closed]

I don't have any code for this since I don't know how I am meant to do this.

I have a car and I am able to move it around on a flat plane and I have that working correctly. However, I want it to also be able to move up hills accurately. So that when I drive up a hill the front wheels start going up first and then the back wheels follow like a normal car would. So far all I have managed to be able to do is when one point of the car reaches an incline the whole car moves to that new y value instead of just the section of the car that is supposed to. Does it require some kind of translation and rotation applying to it so that it reacts correctly?

-

## closed as unclear what you're asking by MichaelT, durron597, Snowman, Kilian Foth, IxrecOct 7 '15 at 20:43

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

When you go up a hill, does your car rotate? To do this realistically you will need to calculate separate positions of the front and rear tires and draw the car according to those positions. – kevin cline Nov 27 '12 at 17:03
it rotates about the axis when I use the arrow keys. Like when I press forward it moves forward and when I press left it turns left. Is there a simple kind of way to look at the bottom of the 4 wheels and the car then translate itself so that all 4 wheels stay touching the ground when they would be at different heights? – user1324894 Nov 27 '12 at 17:09
It's simple to some, not as simple to others. If you can do basic geometric calculations and understand the GL transformation matrix, it's simple. – kevin cline Nov 27 '12 at 17:37
I have managed to do it so that the car moves forward in the direction it's facing is that some kind of start to understanding it? Would it be a rotation of the car with respect to the height of the incline that it is on? – user1324894 Nov 27 '12 at 17:46
In an arbitrary landscape, the position of the car is fixed when there are three wheels on the ground. So you cannot guarantee or expect that the is the fourth wheel is on the ground, too (at least, when the four wheels have a fixed position relative to your car object and you model does not contain something like dampers). – Doc Brown Nov 27 '12 at 22:12