Archived

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

2D collosion detection, Where?

This topic is 5626 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.

http://www.gamasutra.com/features/20020118/vandenhuevel_01.htm

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

Good Luck,
--Hoozit.

(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