I have Two Spheres Sphere 1 is red it is the sphere I want to stand still and not move the seconed sphere wich is white I move with the arrow keys. What I want is with the least amount of code to creat it so when I move the white sphere and it just touches the red sphere that the white sphere wont go through the shpere it instead will sit still like a man pushing agaist a stone building. I want it to work from all sides of the spheres. I have tryde the different collision with if statements but it never worked right Please help COde snippet down below
dbMakeObjectSphere ( 1,33 );
dbMakeObjectSphere ( 2,33 );
dbColorObject(1,dbRgb(255,1,1));
dbPositionCamera(0,50,-80);
dbMoveObjectLeft(1,76);
dbSetObjectSpeed ( 1, 40 );
dbSetObjectSpeed ( 2, 40 );
dbRotateObject(2,0,180,0);
dbRotateObject(1,0,180,0);
dbFixObjectPivot(2);
dbFixObjectPivot(1);
float objmvb=0.0f;
float objmvf=0.0f;
dbSetGlobalCollisionOn();
dbSetObjectCollisionOn(1);
dbSetObjectCollisionOn(2);
float cmrax;
float cmray;
float cmraz;
float cmtrn=0.0f;
dbSetObjectCollisionToSpheres(2); //Prevents Objects from passing through entire person and not just legs.
dbSetObjectCollisionToSpheres(1);
dbAutomaticObjectCollision(1,0.9f,1); //This starts the first one.
dbAutomaticObjectCollision(2,0.9f,1);
//our main loop
while ( LoopGDK ( ) )
{
if (dbLeftKey()||dbRightKey()||dbUpKey()||dbDownKey())
{
cmrax=dbObjectPositionX(2);
cmray=dbObjectPositionY(2);
cmraz=dbObjectPositionZ(2);
dbPositionCamera(cmrax,cmray+50,cmraz-133);
}
else
dbLoopObject(2,209,233);
if(dbLeftKey())
{
dbTurnObjectLeft(2,0.9f);
}
if(dbRightKey())
{
dbTurnObjectRight(2,0.9f);
}
// move the Guy forwards
if ( dbUpKey ( ) )
{
objmvf=objmvf+0.009;
dbMoveObject(2, objmvf);
}
// move the Guy backwards
if ( dbDownKey ( ) )
{
objmvb=objmvb-0.009;
dbMoveObject (2, objmvb);
}
The quality of what a man gives without seeking anything in return shows his integrity.