Hey I\'m a beginner in Dark GDK and I want an object having the same angle as the terrain. On the x axis of the terrain I\'ve already done it. And it works very good. But on the y axis it doesn\'t work really good. I have an attachment; you can test my game then you will see what i mean. If you drive to the right hill and you turn the object around oneself at the half height of the hill, the object adapt themself at the terrain. If you do the same at the left hill, the object only adapt the angle only at 180° of turning it. For better unterstanding, watch my code:
//Heights of the corners of the object
float fHeight = dbGetTerrainGroundHeight ( 1, posx , posz );
float fHeight2 = dbGetTerrainGroundHeight ( 1, posx - 10,posz);
float fHeight3 = dbGetTerrainGroundHeight ( 1, posx,posz - 10);
float fHeight4 = dbGetTerrainGroundHeight ( 1, posx - 10,posz -10);
float a,b;
//Calculation of the angle on Z axis
a = dbATANFULL( fHeight - fHeight3, 10);
//Calculation of the angle on X axis
b = dbATANFULL( fHeight - fHeight2, 10);
//Orientation of the object and query if the limb is in front or behind the object
if(dbLimbPositionZ(10,1) > dbObjectPositionZ(10)){dbXRotateObject(10, a);}
else if(dbLimbPositionZ(10,1) < dbObjectPositionZ(10)){dbXRotateObject(10, -(a));}
//There is no query necessary, but it works better?!
dbZRotateObject(10, b);
I hope you know what I mean.I ask, if the limb is in front or behind the object.Apposite the angle of the object is positive or negative.But on the X axis I don\'t need this query and it works perfect.
Hope you can help me and you understand my baaad english.
Thunder21