Take the 2-minute tour ×

I have a working collision system implemented, and it's based on minimum translation vectors. This works fine in most cases except when the minimum translation vector is not actually in the direction of the collision.

For example:

Ledge collision

When a rectangle is on the far edge on any side of another rectangle, a force can be applied, in this example down, the pushes one rectangle into the other, particularly a static object like a wall or a floor. As in the picture, the collision is coming from above, but because it's on the very edge, it translates to the left instead of back up. I've searched for a while to find an approach but everything I can find deals with general corner collisions where my problem is only in this one limited case.

Any suggestions?

share|improve this question
It seems like a pretty decent collision resolution to me. If two objects barely grazed each other like that, wouldn't you expect them to be shunted to the side rather than knocked directly backwards? –  Eric B Nov 25 '12 at 14:57
In platformer physics or other simple simulations generally a bounding box need to completely clear an obstacle before being allowed to pass, if I'm not mistaken. At least that's the effect I'm going for, so a player on the very edge of an obstacle won't slide through it. It also causes some issues with different obstacle configurations, though that may be unrelated to this specifically. –  ssb Nov 25 '12 at 15:27

2 Answers 2

up vote 0 down vote accepted

You could try doing some apriori collision detection: Test whether they will be colliding after the force is applied, and if it is, only move it until the very beginning of the collision and then stop.

share|improve this answer

You can find the relative velocity vector between both objects and project the objects onto that vector. The overlap along the velocity vector should give you a vector you can use to translate both objects out of collision by 'reversing' them along their velocity vectors. This will normally give you a longer vector than the MTV.

Note this works well only if the objects are rotating relatively slowly.

share|improve this answer
I guess I should clarify that this isn't for realistic physics, and that this problem deals mainly with a player standing on a platform or edging along a wall. I would be OK moving the player back along on the vector he came from, however I don't have a precise way of doing this without generating false positives. –  ssb Nov 25 '12 at 14:37
If that's the case I would look for a clever solution dealing with his acceleration due to gravity being 0 if he's already touching the ground, and his acceleration due to a movement key being 0 if he's already touching a wall, so that he can't move inside an object to such an extent within one frame. –  Eric B Nov 25 '12 at 14:59

Your Answer


