Collision Detection Suggestions

Moderator
Posts: 613
Joined: 2004.09
Post: #1
I started work on a new game, im planning on something between a cross of Mealstorm and Mario Cart. Im doing it in a 2d Overhead view and I plan on racing/shooting mix.

My track consist of beacons which will let the player know where the track is since its set in space. The beacons on merely texturized quads along the x/y axis. Instead of getting too ahead of myself like a normally do I started to think about how I will handle collision detection. In my past games ive always done very simply bounds collision, but I cant grasp a way to do it that way for this kind of setup.

Im looking for suggestions for a method that I can use to test if I have passed through the "beacon path", The only thing that I can think of is drawing lines inbetween each point and testing against crossing that point, but I think that would require a lot of overhead and be rather slow.

The main problem I forsee running into is that each beacon will be space out from the last one so I cant test for hits on just the quads incase the player slips out inbetween the two. Is drawing invisable lines inbetween the quads and testing against that the best way to go here?

Thanks in advance for the insightful feedback.

Kyle Richter
DragonForged.com
Twitter: @kylerichter
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #2
create line strip going around the track in between the two beacons, every point on the line has a thickness, that maximum distance that the beacons are at.. that way the track and get wider and thinner.
for detecting if someone's off the track just see if the center of your ship's smallest distance to the line strip is greater than the thickness at that point,
an explanation of the math's is here:
http://astronomy.swin.edu.au/~pbourke/ge...pointline/

Also, you will probably want to divide the track into parts so you're not doing the long equation with so many line segments at once.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #3
So you have to pass between pairs of beacons that mark out the track? I'd just go for an extra simplistic approach and check the distance of the player against the center of the beacon pairs.

If you want it to be extra specific and actually make them pass between, you could check the collision of two line segments. One between the beacons and one from the players current position to his previous position.

If you actually want to make it like a track, do what unknown said.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #4
Yea im gonna toy around with Unknowns suggestions because you can pass right up aganist a beacon and not be out of bounds.

What im gonna do is draw a line between each beacon and test for a collision along that line, that seems to be the easiest way of doing it so far. Im sure I will need to ask a followup question sooner or later but so far its going well. Thanks guys.

Kyle Richter
DragonForged.com
Twitter: @kylerichter
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Optimize the collision detection alaslipknot 1 2,783 May 12, 2013 08:02 PM
Last Post: SethWillits
  Collision detection tutorial ThemsAllTook 7 22,819 Nov 5, 2011 05:20 PM
Last Post: SethWillits
  Help with Collision Detection..(i'm almost there) carmine 1 4,688 Jun 29, 2011 12:33 PM
Last Post: ThemsAllTook
  Time Delta, collision detection mk12 19 15,630 Sep 8, 2010 06:40 PM
Last Post: AnotherJake
  Collision detection for pinball game johncmurphy 0 4,798 Sep 6, 2009 02:46 PM
Last Post: johncmurphy