Well, basicly, is there a way to make my plane rotate along the world axis, without having it turn to the right when I'm going north, and turn to the left when going south. Because when using dbTurnObjectLeft, the flight runs smooth, exept that first A is to the left, and when I make a 180* turn ut turns to the right when pressing A, and because I roll my plane ( dbRollObjectLeft or something ) I can't rotate it along its own axis, for my plane starts to decent ( because its rotated along its Z axis, the Y axis is not upwards anymore but in an angle ).
I hope I described my problem enough for you to help me.
Isocadia.
PS: Here is my code, if you find anything that could be improved, please tell me:
bool Flying = true;
bool Takeoff = false;
bool Landing = false;
bool space_is_pressed = false;
void MoveAirplane ( int ObjectID )
{
dbPositionCamera ( dbObjectPositionX(ObjectID),dbObjectPositionY(ObjectID),dbObjectPositionZ(ObjectID) );
dbRotateCamera ( dbObjectAngleX(ObjectID), dbObjectAngleY(ObjectID), dbObjectAngleZ(ObjectID) );
dbMoveCamera ( -100 );
if ( dbSpaceKey() == 1 && space_is_pressed == false )
{
space_is_pressed = true;
}
if (dbSpaceKey()==0 && space_is_pressed==true)
{
space_is_pressed=false;
if ( Flying == true )
{
Flying = false;
Landing = true;
Takeoff = false;
}
if ( Flying == false )
{
Flying = false;
Landing = false;
Takeoff = true;
}
}
if ( Flying == true )
{
dbMoveObject ( ObjectID, 2 );
if (dbKeyState (17) == 1) // W
{
float AngleX = dbWrapValue(dbObjectAngleX(ObjectID) + 1.6);
dbXRotateObject ( ObjectID, AngleX );
}
if (dbKeyState (30) == 1) // A
{
float AngleY = 1.2;
dbTurnObjectLeft ( ObjectID, AngleY );
float AngleZ = 1.7;
dbRollObjectLeft (ObjectID,AngleZ );
}
if (dbKeyState (31) == 1) // S
{
float AngleX = dbWrapValue(dbObjectAngleX(ObjectID) - 1.6);
dbXRotateObject ( ObjectID, AngleX );
}
if (dbKeyState (32) == 1) // D
{
float AngleY = 1.2;
dbTurnObjectRight ( ObjectID, AngleY );
float AngleZ = 1.7;
dbRollObjectRight(ObjectID,AngleZ );
}
if ( dbKeyState (32) == 0 && dbKeyState (30) == 0 )
{
if ( dbObjectAngleZ (ObjectID) < -4 ) // D
{
float AngleZ = 1.5;
dbRollObjectLeft (ObjectID,AngleZ );
}
else if ( dbObjectAngleZ (ObjectID) > 4 ) // A
{
float AngleZ = 1.5;
dbRollObjectRight (ObjectID,AngleZ );
}
}
}