I'm writing a simple physics system for fun, and I've run into a problem that has me stuck.
The basic algorithm now is:
- Move an object
- Check for collisions
- If there was a collision
- Move the object the minimum distance to resolve the collision.
- Adjust the velocity based on the normals, masses, etc
I have one moving body moving toward two, static, massless, bodies.

The moving object is translated in one step to collide with one of the bodies.

I respond by finding the smallest distance I can move so that they are no longer colliding. In this case, that means moving the dynamic body straight down. However, now it is colliding with another box.

I repeat the same thing with that box, trying to move the dynamic box so that it is no longer colliding, but that pushes it back into the first box. This repeats forever. Is my algorithm fundamentally flawed?


