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?
5
You will need to keep track of the position of the front and rear of the car separately based on the terrain under the car. Then calculate the transformation matrix directly from the position of the center front and center rear of the car. Compute orthonormal vectors where one is aligned with the direction of the car, a second is horizontal, and the third is the cross product of the others. These vectors will form the GL transformation matrix.
Calculating rotation and pitch angles is an unnecessary excursion into spherical coordinates.
It may be even simpler to use a physics library.
4