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 / ? about value 0 in collision detection.

Author
Message
Sir Spaghetti Code
20
Years of Service
User Offline
Joined: 12th Jul 2004
Location: Just left of Hell
Posted: 26th Jul 2004 13:22
Hello. I was reading the following in a DB tut:

"We use a value of 0 to instruct DarkBASIC that we wish to check for collision against any other object in the scene. By setting it to 0 it will return the value of the object, that object number 10 collides with. This command returns a value of 0 if no collision event is detected. If the value is greater than 0, a collision event is detected and we position the object where it was before it collided"

OK. My question is: By the bolded statement above, the collision check could return a value = whatever the object number is it collided with. Hmmm. I thought it would only return 0 for false and 1 for true. The DBpro (which is what I use) reference guide does not mention anything of this. Any help is appreciated, as if it can return different values, that would make a huge difference in a program. Thanks!

Fraggles where quite the scary lot...
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 26th Jul 2004 13:54
You can use this command in one of two ways:

You can pass two object numbers to check if they collide. The command will then return a 0 or a 1, a 0 to indicate no collision has occured between the specified objects, a 1 to indicate collision is present.

You can also do what you have described, use a value of 0 to check for collision with any object. If there is collision present between the specified object and ANY OTHER object, the command will return the id number of the object that the specified object is colliding with.

One thing I don't know...what if the specified object is colliding with multiple objects? Will it return the object id of the closest one?

I hope I cleared it up

Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 26th Jul 2004 18:20
The 'F1' help AND page 84 of the DBPro reference manual for OBJECT COLLISION states;

Quote: "This command will return a one if the two specified 3D objects are overlapping. If the second object number is set to zero, the number of the object overlapping with the first object will be returned as an integer value. The parameters should be specified using integer
values."


In what way does that not explain things?


Boo!
David T
Retired Moderator
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 26th Jul 2004 18:55 Edited at: 26th Jul 2004 18:55
Basically, if you have two objects and want to check for collision use

object collision(firstobj, secondobj)

if you have object and want to test for collision with any object use

objectitis_hitting = object collision(firstobj, 0)

(the swear filter caught me, "objectitis[/b]hitting")

Get [b]15 new commands, all the date / time commands left out of DBPro for free!
DOWNLOAD PLUGINS HERE: http://www.davidtattersall.me.uk/ and select "DarkBasic"
Sir Spaghetti Code
20
Years of Service
User Offline
Joined: 12th Jul 2004
Location: Just left of Hell
Posted: 27th Jul 2004 07:13
Thank you all!

@Spooky Very odd. Mine does not say that. older ref?

Fraggles where quite the scary lot...

Login to post a reply

Server time is: 2024-11-27 02:35:29
Your offset time is: 2024-11-27 02:35:29