Hello guys
im having a rotation problem:
for example: when my object is rotated by 90 degree on the Y axis, the behavior of rotation around the X axis is the same as the Z axis.
im working on a new game, and trying to find a way to rotate my spaceship around the axes so it looks neat, so in each loop, if the X axis of the spaceship is more than 0, it rotates by -0.1 degree, and if its less, it rotates by 0.1 degree, that happens when im not pressing any button, when i press A or D it should rotate on the Z axis by 0.4 or -0.4, and it also -should- move to the left or to the right slightly along with the Z rotation, and here is the problem, when i move it on the Y axis while it's rotated on the Z axis it changes it's direction in such a weird way.
here is my rotation code:
//turning
if (dbObjectAngleZ(1) != 0)
{
if ( dbObjectAngleZ(1) > 0 )
{
dbZRotateObject(1, dbObjectAngleZ(1)-0.1);
}
else
{
dbZRotateObject(1, dbObjectAngleZ(1)+0.1);
}
}
if (dbKeyState(30) || dbLeftKey()) // -A- left
{
if (dbObjectAngleZ(1) < 20 )
dbZRotateObject(1, dbObjectAngleZ(1)+0.4);
dbYRotateObject(1,dbObjectAngleY(1)-1);
}
if (dbKeyState(32) || dbRightKey()) // -D- right
{
if (dbObjectAngleZ(1) > -20 )
dbZRotateObject(1, dbObjectAngleZ(1)-0.4);
dbYRotateObject(1,dbObjectAngleY(1)+1);
}
if (dbObjectAngleZ(1) > 20) dbZRotateObject(1, 20);
if (dbObjectAngleZ(1) < -20)dbZRotateObject(1, -20);
if (dbObjectAngleY(1) > 360) dbYRotateObject(1, 0);
if (dbObjectAngleY(1) < 0)dbYRotateObject(1, 360);
//end turning
What im doing wrong, oh well i know what is wrong but how to fix it?