views:

20

answers:

1

I want to do a collision detection system for a rectangle to use some physics, so there will be a normal for each of the sides. How do I determine which side of the square was hit by the object. The other object would be a circle.

Thank you.;

A: 

It's hard to know exactly without knowing the library you're using (or seeing your code, if you wrote it yourself), but presumably you're simply looking for overlap in the bodies of the two objects.

The algorithm has to do some sort of math to find out if there are coordinates of one object inside the boundaries of the other object. Assuming that you're just working on an x-y plane, you can compare the center of one object to the overlapping area. Positive delta x, right; negative delta x, left. The y axis would work the same way. This wouldn't necessarily give a guaranteed answer if the corners collided.

Nate