Jump to content
• Advertisement

Advanced 2D Collision det and physics

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, Working on a testbed program for another idea of mine, I decided to implement a slightly improvised pong/breakout like clone. I didnt want to limit myself to horizontal and vertical collisions though, so i decided to implement collisions based soley on lines and circles (4 lines in a rect, etc.) then being able to have the lines skewed. I figured this was also a good way to be able to change the collision type based on which part of a shape was hit (defined by the line segment). I am having a few problems with this approch though.. The most massive I have is... how to define a line? In normal computer terms, i would define it as a pair of X&Y values, but doing that in this case does not provide the information to accuratly detect the collision or the bounce, so i figured having a slope, but then that rules out vertical lines (both vertical and horizontal lines will be commonplace enough for that to pose problems. I thought about using an angle value to specify the slope, but im not sure the drawbacks on that approch. I figure if I do have the angle of skew for the line, i could use that angle to turn some sort of 2d vector and figure out the standard bounce angle, then turn the line again. Or something im the sort. I feel that I am confusing myself, if someone would bother pushing me in the right direction here... LOL. Thanks

Share this post

Share on other sites
Advertisement
Take a look at oliii's website. He has pretty good stuff on collision detection that is worth to be seen.

linky1

EDIT: Also look at his profile. He posted A LOT about the subject.

Share this post

Share on other sites
the simnplest way to do that sort of thing is through vector maths. As you said, a segment is defined by two points, and using vector maths, that's all you need. I can't really explain how the thing would work as it might confuse you if you don't know vector maths, but for a quick intro, have a look at

http://www.geocities.com/SiliconValley/2151/math2d.html

http://www.gamedev.net/reference/articles/article1832.asp

http://collective.valve-erc.com/index.php?doc=1039880877-82189500

some of them are in 3D, but 2D is the same (except maybe for the cross product).

from there, once you're cool manipulating vectors, it's pretty straight forward. It's just geometry. No matter what angle you choose for the line, the equations would be very simple, and work always the same.

Share this post

Share on other sites

• Advertisement
• Advertisement

• Popular Contributors

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5
khawk
14
• Advertisement

• 9
• 11
• 11
• 23
• 10
• Forum Statistics

• Total Topics
633653
• Total Posts
3013152
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!