How to determine collision direction between two rectangles?

Posted by Jon on Game Development See other posts from Game Development or by Jon
Published on 2012-06-14T18:45:34Z Indexed on 2012/06/15 15:28 UTC
Read the original article Hit count: 214

Filed under:
|
|
|

I am trying to figure out how to determine the direction a collision occurs between two rectangles.

One rectangle does not move. The other rectangle has a velocity in any direction. When a collision occurs, I want to be able to set the position of the moving rectangle to the point of impact.

I seem to be stuck in determining from what direction the impact occurs. If I am moving strictly vertically or horizontally I manage great detection. But when moving in both directions at the same time, strange things happen.

What is the best way to determine what direction a collision occurs between two rectangles?

© Game Development or respective owner

Related posts about XNA

Related posts about c#