Hello,
I'm working on a racing game, I've got the car's movement and controls down (at least the prototype version), but I cannot figure out how to rotate the car to fit the matrix landscape I'm using!
I tried several forum searches, didn't find anything there, and looked at the Binary Moon Limit Rush tutorial, but it said:
Quote: "Now that the vehicle is loaded it has become very obvious that it isn't tilting to the landscape as it would in real life.
How do we know what angle the vehicle is at then?
Well we don't. There are a number of math's ways that could work it out for us but I don't want to do any confusing math's tilting the object so that it looks right is more than enough."
A) I would rather learn the correct mathematical way of doing this, as I want it to be as accurate as possible... (I'm guessing I would use ATANFULL()??) and -
B) The method in the tutorial still doesn't look right, especially when the vehicle turns.
So, what I'm asking:
Can someone show me to tell me the correct way to use the FRONT, BACK, LEFT, and RIGHT ground heights of the car, and use those variables with, I'm guessing, ATANFULL() to rotate the car correctly from ANY 'Y' angle?
My current code: (The bit that gets the X & Z positions, and ground heights, of each side of the car)
carFX# = newxvalue(carX#, carAY#, object size z(c)/2)
carFZ# = newzvalue(carZ#, carAY#, object size z(c)/2)
carBX# = newxvalue(carX#, wrapvalue(carAY#+180), object size z(c)/2)
carBZ# = newzvalue(carZ#, wrapvalue(carAY#+180), object size z(c)/2)
carLX# = newxvalue(carX#, wrapvalue(carAY#-90), object size x(c)/2)
carLZ# = newzvalue(carZ#, wrapvalue(carAY#-90), object size x(c)/2)
carRX# = newxvalue(carX#, wrapvalue(carAY#+90), object size x(c)/2)
carRZ# = newzvalue(carZ#, wrapvalue(carAY#+90), object size x(c)/2)
grndF# = get ground height(1, carFX#, carFZ#)
grndB# = get ground height(1, carBX#, carBZ#)
grndL# = get ground height(1, carLX#, carLZ#)
grndR# = get ground height(1, carRX#, carRZ#)
Now what?
Thanks, any and all help greatly appreciated!
-gbark