Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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. Whe have 3 AABB.

  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.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
But wouldn't the problem I stated still exist? Or are you expecting that applying this forces over time bodies will be fully separated?. –  Notbad Jan 31 '12 at 18:38
    
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... –  Cpt. Red Jan 31 '12 at 23:11
    
Seems I have to try this, and it could work. Thanks. –  Notbad Feb 1 '12 at 8:05
    
@Notbad Do accept his answer if this helped you. –  Nick Wiggill Feb 1 '12 at 13:57
    
Sorry, I forgot to accept it. It is done now. –  Notbad Feb 1 '12 at 22:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.