# Collision detection hell !! Need advice..

This topic is 4136 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi everyone. I'm currently working on a 2d puzzle game with four other people that is based around guiding a body of water through a level: I'm running into severe difficulties though with the collision detection, having already tried 4 different approaches to the problem and having no luck with either. I need to be able to move arbitrary sized circles around a level and resolve any collisions with geometry in such a way that the response seems smooth (around corners) and that the circles don't end up in a position where they intersect any other geometry (within most reasonable situations at least). I'm doing a static collision test that is incremented in fixed step sizes of less than the circles radius, this is in case the circle skips over any geometry. I also have a BSP tree generated for the level to help narrow down what lines need to be tested against. So far the most favorable approach has been to find the closest 'hit' point on all lines tested against and move the sphere away from this point so that it is at radius lenght away. Normally this 'hit' point is a point gotten by projecting the circles center point perpendicularily down onto a line, but in some cases it may be either end point of the line (happens when colliding with corners). This approach seems to make for nice smooth response, especially around corner points. However it fails occasionally when the circle gets into a narrow crevice where the angle between the two node lines is acute. What happens in this case is that one line will move the circle along its normal past the other, and the circle will end up going through all the geometry. Has anyone got any suggestions for a collision detection scheme that would produce nice smooth results but still stop the circles from passing through things ? Any help would be greatly appreciated, I think I'm gonna go bannanas if I don't crack this problem soon ! [totally] I have so much other stuff to be working on and can't afford to be spending much more time on this problem. Thanks for your help.

##### Share on other sites
Hi Darragh,

take a look at http://www.geocities.com/oswaldovarela/colisioni.htm. It solved all my collision troubles. It is about "Swept Sphere Collision Detection" but I guess it can be easily adopted to 2D. The PDF http://www.geocities.com/oswaldovarela/zips/colision.zip explains all the theory behind it and also includes source code for collision detection and response.

Hope this helps.

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5

• 9
• 13
• 19
• 14
• 9
• ### Forum Statistics

• Total Topics
632940
• Total Posts
3009329
• ### Who's Online (See full list)

There are no registered users currently online

×