Collision Detection

Started by
1 comment, last by popsoftheyear 15 years, 7 months ago
Hey all, I'm looking for ideas on how to do a collision detection manager. You see, I have to develop a pool game. Now, for a simple game like pong the collisions are easy enough - because u really only have to check collision for 1 object. But with pool I obviously have a number of balls I need to keep track of. I expect I'll need a way to detect all of the collisions before I move the balls... I'm just not sure exactly how to do this. So if anyone knows a good method for this sort of collision detection let me know! Thanks! Ryan
Advertisement
most collision detection algorithms work like this.

Find colliding pairs of objects,
calculate resulting force
repeat for all objects in the scene,
update position of all objects
render
I'm making a pongish breakoutish type of game with multiple balls and use a similar approach. Here is a good resource on ball collision.

Another issue to keep in mind is when the order they collide in. If both balls B and C collide with ball A, you need to figure out which one hit first (let's say it was B), calculate the vector that C would be on after that point in time (same vector but the position is updated and the length of the vector will be smaller), and recalculate to see if there is still a collision between A and C, going from there. Etc. There are quite a few nuances involved with physics and dynamic collision detection which is why there are so many libraries to handle these things now-a-days. Have fun!

Cheers
-Scott

This topic is closed to new replies.

Advertisement