Downloaded and installed GDK yesterday. Got fighter moving around in very short order(real plug&play 3d graphics!). Then decided to make quick&easy avoid walls flight "game". Problem: Camera should be slightly behind and up the fighter all the time. However all attempts to do that have failed big time resulting in plane spiraling out of screen if I use up or down keys and left and right don't look that good either.
Here's relevant code pieces. I have tried to use several functions to get the effect but none have done the trick so far.
dbPositionObject ( 1, 10, 10, 0 ); //position of the fighter initially)
dbMakeCamera(100);
dbPositionCamera (100, 10, 15, -10 );
dbPointCamera(100, 10, 15, 0);
while ( LoopGDK ( ) )
{
dbText ( 0, 0, "Use the arrow keys to manouver the plane" );
if ( dbUpKey ( ) ) {
dbPitchObjectUp(1, 0.5);
dbPitchCameraUp(100,0.5);
}
if ( dbDownKey ( ) ) {
dbPitchObjectDown(1, 0.5);
dbPitchCameraDown(100, 0.5);
}
if ( dbLeftKey ( ) ) {
dbRollObjectRight ( 1, 1.5 );
dbRollCameraRight(100, 1.5);
}
if ( dbRightKey ( ) ) {
dbRollObjectLeft ( 1, 1.5 );
dbRollCameraLeft(100, 1.5);
}
dbMoveObject ( 1, -1.0 );
//dbSetCameraToFollow(dbObjectPositionX(1),dbObjectPositionY(1),dbObjectPositionZ(1), 0, 20, 5, 1, 0);
dbMoveCamera(100, 1.0);
//dbPositionCamera(dbObjectPositionX(1),dbObjectPositionY(1)+5,dbObjectPositionZ(1)-10);
//dbPointCamera(dbObjectPositionX(1),dbObjectPositionY(1) +5,dbObjectPositionZ(1));
So. Any idea what I'm doing wrong big time?