Need help ..when i press forward object 1
a/ is stuck or its resetting its position to the same spot
b/ flies try object 2 at 45% degrees downwards
c/ goes all around try object 2 and it cant stop in some kind of melting motion.
if anyone could direct me what i am doing wrong or corect the code i would greatly appreciate
#include "DarkGDK.h"
#include "dinput.h"
#include "SC_Collision.h"
void DarkGDK ( void )
{
//Define some local variables.
int collide = 0;
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
SetCurrentDirectory ( "media" );
dbLoadObject("bchar.x",1);
dbLoadObject( "exa.dbo", 2 );
dbPositionObject(1,0,0,0);
SC_Start();
SC_SetObjectCollisionOn(1);
SC_SetObjectCollisionOn(2);
SC_SetupObject(1,1,1);
SC_SetupComplexObject(2,2,2);
// our main loop
while ( LoopGDK ( ) )
{
float oldx = dbObjectPositionX(1);
float oldy = dbObjectPositionY(1);
float oldz = dbObjectPositionZ(1);
if(dbKeyState(DIK_W))
dbMoveObject(1,10.0f);
if(dbKeyState(DIK_S))
dbMoveObject(1,-10.0f);
if(dbKeyState(DIK_D))
dbYRotateObject(1, dbObjectAngleY(1) + 5);
if(dbKeyState(DIK_A))
dbYRotateObject(1, dbObjectAngleY(1) - 5);
//Camera.
dbPositionCamera (dbObjectPositionX(1), dbObjectPositionY(1) + 100, dbObjectPositionZ(1));
dbSetCameraToObjectOrientation(1);
dbMoveCamera(-300);
//Check collision.
float x = dbObjectPositionX(1);
float y = dbObjectPositionY(1);
float z = dbObjectPositionZ(1);
int collide = SC_SphereSlide( 1, oldx,oldy,oldz, x,y,z, 2.0f, 0 );
if (collide > 0)
{
ddbPositionObject(1 , SC_GetCollisionSlideX(),SC_GetCollisionSlideY(),SC_GetCollisionSlideZ() );
dbText( 0,20,"HIT!!" );
}
SC_UpdateObject(1);
SC_UpdateObject(2);
dbSync();
}
}