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.

DarkBASIC Professional Discussion / Multiple Collision

Author
Message
StephenRussell
15
Years of Service
User Offline
Joined: 18th Nov 2010
Location: UK
Posted: 19th Nov 2010 17:30
Hi,

I had a search of the forums and couldn't seem to find anything on this... How do I check multiple collisions, without writing them all out? I mean, I've created 5,000 tree's in a 3d world. How can I stop the player running through these?

Without writing
if object collision(1,2) then.........
if object collision(1,3) then.........
if object collision(1,4) then.........
if object collision(1,5) then.........
if object collision(1,6) then.........
.....
....
...
..
.

Thanks for the help in advance

If first of all you don't succeed, it's probably not worth doing.
LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 19th Nov 2010 17:54
collide = object collision(1,0)


From the help files:
Quote: "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."


Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 19th Nov 2010 18:13
Quote: "collide = object collision(1,0)"


Or failing that, you could have used a for-next loop You're new to the forums so I suggest you look up on them if you haven't already, they're very useful.

StephenRussell
15
Years of Service
User Offline
Joined: 18th Nov 2010
Location: UK
Posted: 19th Nov 2010 18:24
Quote: "collide = object collision(1,0)


From the help files:

Quote: "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."

"


Ah excellent, thanks That's the reply I needed
Sorry, I'm new so I'm still getting to grips with it all!

If first of all you don't succeed, it's probably not worth doing.
StephenRussell
15
Years of Service
User Offline
Joined: 18th Nov 2010
Location: UK
Posted: 19th Nov 2010 18:34
Oh another quick question. How can I get collision to ignore one? using "collideID = object collision(1,0)"

thanks again

If first of all you don't succeed, it's probably not worth doing.
Mugen Wizardry
User Banned
Posted: 19th Nov 2010 21:13
for x=1 to maxenemies
coll=object collision(x,0)
next x

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 19th Nov 2010 21:34
Quote: "for x=1 to maxenemies
coll=object collision(x,0)
next x"


It would be



in this specific case, your code would basically check for any collision at all in the game

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 19th Nov 2010 23:06
You could also turn off the collision so it doesn't even check it in the first place:



Or, exclude it:



TheComet

StephenRussell
15
Years of Service
User Offline
Joined: 18th Nov 2010
Location: UK
Posted: 22nd Nov 2010 10:42
Thanks 'TheComet', that's exactly the answer I needed... not sure why / how I didn't think of that though

I only want to exclude a couple of objects so scanning collision on EVERY OTHER ONE would destroy my fps.

If first of all you don't succeed, it's probably not worth doing.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 22nd Nov 2010 14:32
If you combine all of your 'collision objects' into one object you'll get an increase in performance. You could just check for a collision with one object.

StephenRussell
15
Years of Service
User Offline
Joined: 18th Nov 2010
Location: UK
Posted: 22nd Nov 2010 16:27
Thanks for the advice baxslash, but that could be a little hard with an unlimited terrain

But I will merge any collision models where I can!

If first of all you don't succeed, it's probably not worth doing.

Login to post a reply

Server time is: 2026-07-21 12:51:20
Your offset time is: 2026-07-21 12:51:20