I have a lot of AABB bouncing on the screen. Doing collision/response between 2 AABB is fairly easy, but how do you handle this when you can be pulling AABB's apart but making them getting into another AABB? I mean something like this scenario:

  1. We have 3 AABBs.

  2. We check if first one collides with the other two. No collision is found.

  3. We check if second collides agains the third (we don't need to recheck agains first). We find a collision, we separate second AABB form third but it intersects now with first one.

This will produce a bad response/collision detection. How do you handle this chained collisions?

Edit: I forgot to say that all aabb are dynamics objects. I mean, they move.


1 Answer 1


Most physics engines that I have seen/used solves this problem by apply a force to the objects instead of directly changing the positions. This does it so that we only need to check collisions once between each object(or not even that if one is using culling algorithms) per update.

e.g. if you only have circles you simply give colliding objects a force away from the centre that is scaled to how close the other object is. AABBs is also somewhat simple as long as you don't need to rotate them. When I implemented a simple physics system(although we used OBBs but we still didn't care about angular velocity) we pushed the objects in the direction of its the closest edge.

  • \$\begingroup\$ But wouldn't the problem I stated still exist? Or are you expecting that applying this forces over time bodies will be fully separated?. \$\endgroup\$
    – Notbad
    Jan 31, 2012 at 18:38
  • \$\begingroup\$ Yes they should separate very quickly as long as you scale the forces properly(just try out some numbers and you will and be fine). Remember that both of the objects in a collision push on eachother... \$\endgroup\$
    – Cpt. Red
    Jan 31, 2012 at 23:11
  • \$\begingroup\$ Seems I have to try this, and it could work. Thanks. \$\endgroup\$
    – Notbad
    Feb 1, 2012 at 8:05
  • \$\begingroup\$ Sorry, I forgot to accept it. It is done now. \$\endgroup\$
    – Notbad
    Feb 1, 2012 at 22:08

You must log in to answer this question.

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