Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


2D collosion detection, Where?

This topic is 5932 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

sorry that it''s long, and my bad english.. lets say i have 2 balls, A & B, and i need to know if A hitted B, and where in A the collisoin happend, because i need to know how to update the movment of the balls.(if a ball went north-east, it''ll go south-east if he got hit from above, and north-west if he got hit from the left) what i did is to check if the delta on the "x''s" is bigger the delta on "y''s", the ball came from above or below... so act as you should, else, the ball came from the right or the left... this handle the "down" hit, the "up" hit looks the same so it''s not here if(Pos->top < B->top) { if(Pos->top < B->bottom) return NOHIT ; else if(Pos->left > B->right || Pos->right < B->left) return NOHIT ; else if(Pos->left > B->left) if(B->right - Pos->left > abs(Pos->top - B->bottom)) return HITD ; else return HITR ; else //// Pos->left < B.left if(Pos->right - B->left > abs(Pos->top - B->bottom)) return HITD ; else return HITL ; } now, what''s the problem? if a ball moves at speed 10 on the x, and speed 1 on the y, it''ll go so fast on the "x''s" and in the first time it''ll hit another ball from the bottom, the "x''s" delta will be bigger... so how do i solve this problem? or where can i find "known" better way to do it? 10x... Logic can take you from Point A to Point B, But dreams can take you ANYWHERE

Share this post

Link to post
Share on other sites
Check out this great article on Gamasutra.com that shows how to calculate collision response for pool (billiards) balls. It sounds like just what you're looking for.


(Sorry that I don't have time to look at your code; I just thought the article might be helpful for you.)

Good Luck,

(edit: changed "tutorial" to "article".)

[edited by - HoozitWhatzit on July 23, 2002 1:46:20 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!