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.

This question already has an answer here:

My game processes world collisions followed by entity collisions. The problem here is that entities can break through walls the next frame when world checks are run again as a result of the prior collision resolution. For example:

  1. Entity1 is up against a wall and pushing against it
  2. Entity2 runs into Entity1, collision detection resolves Entity1 inside the wall.
  3. World collisions push Entity1 onto the other side of the wall.

What happens is that Entity2 pushes Entity1 into the wall far enough that when the world collision detection attempts to find the shortest distance out of the wall, that position happens to be on the other side.

share|improve this question

marked as duplicate by Sean Middleditch, Byte56, bummzack, Ali.S, Anko Apr 7 '13 at 16:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Multibody collisions (more than 2 bodies) are a big physics topic with no true computational way of solving it perfectly. If these Entities have momentum (mass and velocity) then you can try and apply the concept of conservation of momentum treating the wall as an Entity with infinite mass. –  RobCurr Mar 4 '13 at 17:08

1 Answer 1

up vote 1 down vote accepted

The place to fix it is in step 2.

If Entity2 runs into Entity1, Entity1 gets moved, but only if the resulting location is not a new collision. In that case you'll have to move Entity2 back to it's original position or some other custom solution (for example: try moving Entity1 to a different direction that doesn't cause a collision).

share|improve this answer

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