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.

Newcomers DBPro Corner / I need some help with a simple Collision code

Author
Message
JABBER
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Indiana, USA
Posted: 4th Sep 2006 22:42
I've been trying to get a simple ball to fall till it contacts the floor. But no matter what I do it always says the object are "touching"(col# always = 1)

here's the code----



I'm greatful for any insight, thanks again for your time guys,

JABBER

Retired DEV team member Targetware.net
Retired DEV team memeber BF 1918 MOD
http://hosted.filefront.com/JABBER1975
JABBER
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Indiana, USA
Posted: 5th Sep 2006 02:25
I've been messing around with it and found if the floor was moved -1 down the Yaxis or if move +4 or more, than the two objects fall thourth each other with out col# ever equaling 1. You might noticed I tried a different collision method also printing out the collision radius of the two objects



Thanks again, JABBER

Retired DEV team member Targetware.net
Retired DEV team memeber BF 1918 MOD
http://hosted.filefront.com/JABBER1975
Daemon
18
Years of Service
User Offline
Joined: 16th Dec 2005
Location: Everywhere
Posted: 5th Sep 2006 02:37
It's hard to tell without the media, but I have to ask: Why do you make col#=object hit(3,2) before the do...loop instead of inside of it? Do you realize that it only is checking if they hit once?

JABBER
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Indiana, USA
Posted: 5th Sep 2006 06:19
That sounds like a big part of the problem. I should make a no media version if this doesn't work,
Thanks Daemon

Retired DEV team member Targetware.net
Retired DEV team memeber BF 1918 MOD
http://hosted.filefront.com/JABBER1975
JABBER
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Indiana, USA
Posted: 5th Sep 2006 06:36
Well if I replace the .X models with coded geometery it works perfecrtly.
check it out


Any Ideas on what might be wrong with my .X models? I'll post sceenies of my Panda X export settings if it would help. THANKS

JABBER

Retired DEV team member Targetware.net
Retired DEV team memeber BF 1918 MOD
http://hosted.filefront.com/JABBER1975
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 5th Sep 2006 14:25
Its because using the built in object collision commands means using box collision, which is basically where DBP draws two boxes around the two objects colliding. These boxes go to the object's extents on all 3 axises, and if these 2 objects overlap, a collision is recorded. Even if you had a level, like this;



The box for that level would look like;


Which is why usually any game that requires serious collision, whereby you actually want to know if the object is touching a polygon and not thin air, you use raycasting. For example, here's a basic one;



I dont have time to explain it right now, but look up intersect object and raycast on the forum boards to get more info. Also, look into getting Sparky's Collision dll, its much faster than DBP's built in intersect object command and comes with a tonne of others to help with collision, including a sliding collision command set.

Also, if your heart is set on using the built in collision commands (I really hope not) then look up POLYGON in the help file until you find the command that sets object collision to mode "POLYGON", I forget which command it is or Id say, I think its "SET POLYGONAL COLLISION ON".

Your signature has been erased by a mod because it's larger than 600x120...
JABBER
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Indiana, USA
Posted: 5th Sep 2006 17:47
Thanks Ruccus, I'll start reading up on raycasting, and I'll look for the sparky .DLL. Thanks guys

Retired DEV team member Targetware.net
Retired DEV team memeber BF 1918 MOD
http://hosted.filefront.com/JABBER1975
JABBER
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Indiana, USA
Posted: 5th Sep 2006 18:42
I have it! I think the col#= object collision (2,3) being in the main loop did the trick after I changed the collision to polygons. The "ball" did sink a little to far into the floor before it detected the collision but I changed the radius and it works well, now I'm working on some very simple pyshics, a bounce subroutine, which is a little above my head at this point. I my need to start a another topic but I'll throw the code here because you guys have been very helpful,
As it is now the ball hits the floor and just bouces back up to an altitude of "1" then back to the floor in a loop lasting about 10ms in cycle.
I know when you guys see this code you'll laugh, But it's my first try at something like this, Thanks for help guys. I'd be bald (or atleast more bald) if I was doing this alone.
JABBER


Retired DEV team member Targetware.net
Retired DEV team memeber BF 1918 MOD
http://hosted.filefront.com/JABBER1975

Attachments

Login to view attachments
JABBER
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Indiana, USA
Posted: 6th Sep 2006 03:14 Edited at: 6th Sep 2006 03:14
That works great for detecting a flat floor with no walls, what would be the best method with walls, the raycasting? having some REAL troubles with that one.

Here's the code--


uploaded the project with media also---

Thanks JABBER

Retired DEV team member Targetware.net
Retired DEV team memeber BF 1918 MOD
http://hosted.filefront.com/JABBER1975

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-09-25 07:21:08
Your offset time is: 2024-09-25 07:21:08