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 / Collision Detection?

Author
Message
Erk
16
Years of Service
User Offline
Joined: 26th Feb 2008
Location:
Posted: 27th May 2009 02:31
Here's my question.
I have a cube that moves around with the mouse. What I want to happen is if the cube intersects with any object on screen, it turns red.

I don't want the collision to affect anything, just trip a boolean inside the code

How can I do this?
Thank you for your help
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 27th May 2009 02:45
Maybe somethng like this?



<-- Spell based team dueling game!
Erk
16
Years of Service
User Offline
Joined: 26th Feb 2008
Location:
Posted: 27th May 2009 02:50
Thank you for the response.
Just before you posted I mean to edit this and make on thing more clear.
"any object on screen"
And the player can have hundereds.

I figure, your code in a for-loop would work but it'd be horrifically inefficient.
Is there a better implementation or am I just going to have to live with it?
Deego
16
Years of Service
User Offline
Joined: 21st May 2008
Location:
Posted: 27th May 2009 03:24
Do the same thing, but change this:



Where MinObject and MaxObject is the range of objects that will turn the cube red. You'll need to organize your code in a way that you can do this easier; load all appropriate objects in a group.
Erk
16
Years of Service
User Offline
Joined: 26th Feb 2008
Location:
Posted: 27th May 2009 03:34 Edited at: 27th May 2009 07:50
Thanks for the help.

Getting the MaxObject shouldn't be a problem. I have a function that returns the next available object number, if I subtract one from that, I'll have the range

EDIT: Ok, it works perfectly fine with a cube, but the program freaks out when it's comparing a Sphere. It thinks it's always colliding with the floor. Any help?
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 27th May 2009 08:35
move it a bit above the floor?

Login to post a reply

Server time is: 2024-09-28 06:24:57
Your offset time is: 2024-09-28 06:24:57