Sign in to follow this  

Circular Hit Boxes Math Question

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

Say I have two objects and I want to create circular hitboxes. I have the center of each point and a radius: point1 (x1 ,y1, r1); point2 (x2, y2, r2). I am using a 2D coordinate system where upper left is 0,0, x increases to the right, y increases to the bottom. How do I test for collision between these circles?

Share this post


Link to post
Share on other sites
Upon further reflection, this has a simple answer. Test the distances between the centers! Duh. If at any point the distance of between (x1, y1) and (x2, y2) is <= r1+r2, then I've got a collision.

Duh.

Sorry.

Share this post


Link to post
Share on other sites
'Circular hitboxes', huh? Hehe... :-)

Anyway, testing for intersection between two circles is super-easy. If the distance between the centers of the circles is less than the sum of their radii, there is an intersection. (In practice, squared distances are usually compared for the sake of efficiency.)

You can also easily derive other collision data (minimum translational vector, collision point and normal, etc.) from this info if needed.

The continuous version of the test is also pretty straightforward (it basically reduces to a segment-circle intersection test).

[Oops, too late!]

Share this post


Link to post
Share on other sites

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this