I implemented collision detection in my game using SAT. The detection works, but I'm trying to use the algorithm to figure out the penetration vector of the two OBBs and push them apart (before doing the 'actual' collision handling).

I think I got the penetration vector successfully. However I'm not sure which of the two entities in the collision to apply it on (i.e. add to the position of which entity).

If I apply it on both entities, obviously nothing happens. How can I know to the position which entity I need to add the penetration vector so the entities 'touch' at the exact point of collision?

  • 1
    \$\begingroup\$ You will can resolve the collision in any number of ways. It sounds like you should try moving both objects along the collision normal that SAT found by how deeply they are penetrating each other. \$\endgroup\$
    – RandyGaul
    Jun 22, 2014 at 21:56

1 Answer 1


Common, easy but ultimately wrong answer

Iterate along the vector in very small increments. Eventually they'll de-penetrate at a "reasonable" position, assuming you continue any additional constraints at each iteration. It's brute force, and for something simple, it's good enough. You will almost certainly need to add artificial max/min force limiters to your collision handler if you take this approach. If you don't like limiters, a high dampener, drag or friction value will hide any numerical issues. If you're making a phone game or doing a weekend jam, this will do the trick. See: Better Answer.

Better answer

Wind back time using the last known position and your SAT penetration vector to find the correct time delta between frames of the collision. Don't artificially de-penetrate, re-calculate the physics from the time step at which the collision occurred.

When you de-penetrate then process collisions, you're effectively violating conservation of energy. You've taken an inelastic collision and turned it into an simple elastic collision without doing anything with the forces involved. You've either not absorbed them in the inelastic "crunch" that should have happened or if you're using a fixed coefficient of restitution you may over-compensate. Many physics engines don't handle that well. Depending on what kind of iterator you're using in your physics engine, you can run into numerical problems as well. Verlet iterators are pretty tolerant to that kind of thing because they're inherently positional, but others are not. If the extra error from force-moving objects accumulates your physics can become unstable over time.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .