Hi guys!
Recently I spent some bucks for DarkPhysics purchase and I was hoping that I will save some time, making my character move and jump around a terrain. But I realized that nothing (ok, almost nothing) works!
First, my character controller (CC) does not collide properly with the terrain.
Second, I didn't manage get the dbPhySetCharacterControllerDisplacement function to work.
The CC jump is not a simple task as I thought.
Here is my code:
#include <DarkGDK.h>
#include <DarkPhysics.h>
void DarkGDK ( void )
{
int nTerrain=1, nDrop=2;
float fDropW, fDropH, fDropD;
dbSyncOn ();
dbSyncRate(60);
dbSetWindowOn();
dbSetDisplayMode(800, 600, 16);
dbColorBackdrop( dbRGB(0, 0, 0) );
dbLoadObject( "Dev/Level01.x", nTerrain );
dbMakeObjectBox(nDrop, 0.2f, 1.0f, 0.2f);
//dbLoadObject( "Dev/Drop.x", nDrop );
dbPositionObject(nDrop, 0.0f, 2.72f, 0.0f);
fDropW = dbObjectSizeX(nDrop);
fDropH = dbObjectSizeY(nDrop);
fDropD = dbObjectSizeZ(nDrop);
dbPhyStart();
dbPhyMakeRigidBodyStaticMesh( nTerrain );
dbPhyMakeBoxCharacterController(nDrop, dbObjectPositionX(nDrop), dbObjectPositionY(nDrop), dbObjectPositionZ(nDrop), fDropW, fDropH, fDropD, 1, fDropH*0.01f, 65.0f);
while ( LoopGDK ( ) )
{
if ( dbLeftKey() )
dbTurnObjectLeft(nDrop, 5.0);
else if ( dbRightKey() )
dbTurnObjectRight(nDrop, 5.0);
if ( dbUpKey() )
dbPhyMoveCharacterController(nDrop, 1.3f);
else
dbPhyMoveCharacterController(nDrop, 0.0f);
if ( dbSpaceKey() )
dbPhySetCharacterControllerDisplacement(nDrop, 0.0f, 5.0f, 0.0f);
dbSetCameraToFollow(dbObjectPositionX(nDrop), dbObjectPositionY(nDrop), dbObjectPositionZ(nDrop), 0.0f, 2.5f, 0.5f, 25.0f, true);
dbPhyUpdate();
dbSync( );
}
}
Does anyone knows how to implement this task with GDK commands, please?
Thanks in advance.