hello,
I am quite new to dark gdk and i am trying to make a rotate when going up a hill. i have successfully done forward and backward using 2 boxes that are in different positions. the first is at the front and the second is at the back. it works by one of the boxes pointing towards the other block and then the car is equal to the angle X and Z.
however, I am stuck by rotating the car to the side. I have tried using arc sin and arc tan to rotate but it doesnt work.
float diff = height3 - height4;
float diff2 = height4 - height3;
float dist = distanceBetween2Points(dbObjectPositionX(6), dbObjectPositionY(6),dbObjectPositionZ(6),
dbObjectPositionX(7),dbObjectPositionY(7),dbObjectPositionZ(7));
float add = asin(diff/dist);
float add2 = asin(diff2/dist);
float degrees = add * 180 / 3.1415926;
float degrees2 = add2 * 180 / 3.1415926;
if (height3 > height4)
{
dbXRotateObject(3,dbObjectAngleX(3) + degrees);
dbZRotateObject(3,dbObjectAngleZ(3) - degrees);
}
else if (height3 < height4)
{
dbXRotateObject(3,dbObjectAngleX(3) + degrees2);
dbZRotateObject(3,dbObjectAngleZ(3) - degrees2);
}
else
{
}
object 3 is the car
object 6 is the box to the left
object 7 is the box to the right
does anyone know how to rotate the car in all directions
thanks in advance