Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / help on collision

Author
Message
acurrate eye
15
Years of Service
User Offline
Joined: 28th Aug 2009
Location: ur house under your pillow was under bed
Posted: 2nd Oct 2009 18:48
I have been using dark gdk but when i try to collide with an object its not working i have my guy moving above the land but not stopping when i hit the object please help i tried for 2 weeks

kyle
Ultimate_H
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location: A place that is neither here nor there
Posted: 2nd Oct 2009 22:06
I would suggest putting the old x/y/z positions into temporary variables, moving the object, checking for a collision, and if it is colliding, just move it back to where it was using the temporary variables.
SFCBias
15
Years of Service
User Offline
Joined: 8th Aug 2009
Location: Hephzibah, GA, USA
Posted: 3rd Oct 2009 00:06
We can help you if you include some source code of what you have so far
SFCBias
15
Years of Service
User Offline
Joined: 8th Aug 2009
Location: Hephzibah, GA, USA
Posted: 3rd Oct 2009 17:08 Edited at: 3rd Oct 2009 17:09
I answered a thread similar to this where i suggested the sparky sliding demo. I included some source , that should help, its what im using and it works fine.


http://forum.thegamecreators.com/?m=forum_view&t=157884&b=22&msg=1857327#m1857327
acurrate eye
15
Years of Service
User Offline
Joined: 28th Aug 2009
Location: ur house under your pillow was under bed
Posted: 3rd Oct 2009 19:56
this is my code it is pretty simple im beginning ill put full code on moday or tuesday im at a library dat means number ill get to it as soon as i can and fix it monday or tuesday im doing off memery
include "DarkGDK.h"

dbSync();
dbSyncRate(60);

dbLoadObject("Colenel-X.X",1);//load colenel-x.X
dbScaleObject(1,dat,dat,dat);
dbRotateObject(1,dat,dat,dat);

//terrain Functions i used the one in tutorials =(2)

dbLoadObject(ent.X,3);// this is beams to hold up the outpost
dbPositionObject(3,X,Y,Z);
dbCopyObject(4,3);
dbPositionObject(3,X,Y,Z);
//did this till 4 posts

dbLoadObject(top,9);
dbPositionObject(9,X,Y,Z);
dbScaleObject(9,dat,dat,dat);

dbLoadObject("ladder.X",10);//ladder climb up but i go up farther //away than i need
dbPositionObject(10,X,Y,X);
dbScaleObject(10,X,Y,Z);

dbLoadObject("plat.X",11);// platform you go up in
dbPositionObject(11,X,Y,X);
dbScaleObject(11,dat,dat,dat);
dbSetObectRadius(11,10.0f);

while (darkgdk())
{
if(dbEscapeKey()==1)
{
return;
}
//camera functions to folo colenel.x
//camera functions that if you turn camera turns
dbPositionObject(1,dbObjectPositionX(1),dbObjectPositionY(2)+0.01f,dbObjectPositionZ(1));
// function that if colenel.X is on the plat form he stays on till
//he doesn't touch it anymore /still doesnt work



//moving functions



//collision stinks it move object up 50 ft away than instead of letting him collide then go up ladder.X
if(dbObjectCollision(1,10)==1)
{
dbMoveObjectUp(1,150.0f);
}

//function that deletes all objects when closes
return;
}

kyle
acurrate eye
15
Years of Service
User Offline
Joined: 28th Aug 2009
Location: ur house under your pillow was under bed
Posted: 6th Oct 2009 01:10
this is the code

#include "DarkGDK.h"

bool WalkingIsTrue = false;

void DarkGDK ( void )
{

dbSyncOn ( );
dbSyncRate(60);
dbMaximizeWindow();
dbHideMouse();

dbLoadObject("Colonel-X.X", 1 );
dbRotateObject(1,0,180,0);
dbScaleObject ( 1, 10.0f, 10.0f, 10.0f );
dbPositionObject(1,dbObjectPositionX(2)+575.0f,dbObjectPositionX(2)+2.0f,dbObjectPositionZ(2)+525.0f);


dbLoadObject("ent.X",3);
dbScaleObject(3,100.0f,100.0f,100.0f);
dbPositionObject(3,dbObjectPositionX(2)+600.0f,dbObjectPositionX(2)+1.0f,dbObjectPositionZ(2)+600.0f);
dbRotateObject(3,0,90,-90);
dbCloneObject(4,3);
dbPositionObject(3,dbObjectPositionX(2)+500.0f,dbObjectPositionX(2)+0.0f,dbObjectPositionZ(2)+590.0f);
dbCloneObject(5,3);
dbPositionObject(3,dbObjectPositionX(2)+590.0f,dbObjectPositionX(2)+0.0f,dbObjectPositionZ(2)+500.0f);
dbCloneObject(6,3);
dbPositionObject(3,dbObjectPositionX(2)+500.0f,dbObjectPositionX(2)+0.0f,dbObjectPositionZ(2)+500.0f);


dbLoadObject("plat.X",8);
dbPositionObject(8,dbObjectPositionX(2)+550.0f,dbObjectPositionX(2)+130.0f,dbObjectPositionZ(2)+570.0f);
dbScaleObject(8,100,150,150);
dbRotateObject(8,90,0,0);


dbLoadObject("top.X",10);
dbPositionObject(10,dbObjectPositionX(10)+550.0f,dbObjectPositionX(10)+250.0f,dbObjectPositionZ(10)+560.0f);
dbScaleObject(10,10000,10000,500);
dbRotateObject(10,90,0,0);



dbLoadImage("texture.jpg",1);
dbLoadImage("detail.jpg",2);
dbSetupTerrain();
dbMakeObjectTerrain(2);
dbSetTerrainHeightMap(2,"map.jpg");
dbSetTerrainScale(2,3.0f,0.6f,3.0f);
dbSetTerrainLight(2,1.0f,-0.25f,0.0f,1.0f,1.0f,0.78f,0.5f);
dbSetTerrainTexture(2,1,2);
dbBuildTerrain(2);



dbLoadObject("sky.X",7);
dbSetObjectLight(7,0);
dbSetObjectTexture(7,3,2);
dbScaleObject(7,50000,40000,40000);
dbRotateObject(7,90,0,0);
dbPositionObject(7,500,9,500);


dbLoadObject("ladder.X",11);
dbPositionObject(11,dbObjectPositionX(3)-20,dbObjectPositionY(2)+160,dbObjectPositionZ(3)+30);
dbRotateObject(11,90,90,0);
dbScaleObject(11,10,10,10);
dbSetObjectRadius(1,5.0f);



while ( LoopGDK ( ) )
{

dbPositionCamera(dbObjectPositionX(1)+1.5f,dbObjectPositionY(1)+7.0f,dbObjectPositionZ(1));
dbMoveCamera(-3.0f);
dbRotateCamera(dbObjectAngleX(1),dbObjectAngleY(1)-180,dbObjectAngleZ(1));



float fHeight = dbGetTerrainGroundHeight ( 2, dbObjectPositionX (1), dbObjectPositionZ (1) );
dbPositionObject( 1,dbObjectPositionX (1), fHeight + 1.0f, dbObjectPositionZ (1) );




if(dbObjectCollision(1,8))
{
dbPositionObject( 1,dbObjectPositionX(1),dbObjectPositionY(8)+20.0f, dbObjectPositionZ(1));
}

if(dbObjectCollision(1,11)==1)
{
dbMoveObjectUp(1,130.0f);
}



if(dbUpKey()==1)
{
dbMoveObject(1,-8.0f);
WalkingIsTrue = true;
}
else(WalkingIsTrue = false);

if(dbDownKey()==1)
{
WalkingIsTrue = true;
dbMoveObject(1,8.0f);
}
else(WalkingIsTrue = false);

if(WalkingIsTrue = true==1)
{
dbLoopObject(1,300,318);
}
else(WalkingIsTrue = false);

if(dbLeftKey()==1)
{
dbTurnObjectLeft(1,5);
}
if(dbRightKey()==1)
{
dbTurnObjectRight(1,5);
}
if(dbRightKey()==0) if(dbUpKey()==0) if(dbLeftKey()==0) if(dbDownKey()==0)if(dbShiftKey()==0)
{
dbLoopObject(1,210,232);
}
if(dbShiftKey()==1)
{
dbMoveObjectUp(1,1.0f);
}


if(dbObjectPositionY(1)==14.0f)
{
dbMoveObjectDown(1,1.0f);
}

if(dbObjectCollision(1,3)==1)
{
dbMoveObject(1,0.0f);
}

dbSync();
}

for ( int i = 1; i < 50; i++ )
dbDeleteObject ( i );

// return back to windows
return;
}

if you can't do it try try again and if you still cant do it ask for help
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 6th Oct 2009 01:20
I might be wrong for I don't use Dark GDK's built in collision system but don't you have to set each object up for collisions before the collision detection will work? Try testing out these:

Quote: "void dbSetObjectCollisionToSpheres ( int iObject )
void dbSetObjectCollisionToBoxes ( int iObject )
void dbSetGlobalCollisionOn ( void )
void dbMakeObjectCollisionBox ( int iObject, float X1, float Y1, float Z1, float X2, float Y2, float Z2, int iCollisionFlag )
void dbAutomaticObjectCollision ( int iObject, float fRadius, int iResponse ) "


Your bedtime story is scaring everyone
acurrate eye
15
Years of Service
User Offline
Joined: 28th Aug 2009
Location: ur house under your pillow was under bed
Posted: 8th Oct 2009 22:59
im starting to learn sparkies but ill try what you have

now onto ai

if you can't do it try try again and if you still cant do it ask for help

Login to post a reply

Server time is: 2024-11-20 13:41:04
Your offset time is: 2024-11-20 13:41:04