   Hopefully simple collision resolution question
  Evening chaps.So basically, I've been reading a lot about 2D collision detection and response recently. Most of it makes complete sense and I feel I could use it practically.But just one thing. Most, collision detection techniques seem to rely on detecting when objects ARE intersecting and resolve them so that they are not, before applying appropriate impulses. However, none of what I have read has really elaborated on this point and explained how to resolve it.It seems simple enough when only one object is involved. Just move it back until it ceases to intersect. However, what happens when moving it back causes it to be intersecting with another object?I simulated this with a bunch of circles modelling balls and I ended up with circles caught inside other circles.If anyone can help, it is most appreciated. And thanks for taking the time to read at any rate.   
  I would be careful about claims regarding "most" of anything, particularly with regard to "most" resolve intersections in any particular way. First, you're extending the definition of "collision detection technique" to include resolution algorithms- that's not collision detection. Second - none of the engines I've used resolve collisions as you describe.The physics portion (not the collision detection portion) of ODE (and I believe Havok), for instance, allow either the user to apply the physics or, using the "built-in" physics engine, implement forces (not impulses) as a function of the depth of penetration between objects along the normal at the point of intersection - summing those forces over all the collisions on a single object. The resolution is not done by "just moving the object back" until it ceases to intersect. That method (as you realize) is extremely simplistic and will can result in situations as you describe.Although the above-mentioned engines are implemented in 3D, they can certainly be used for 2D and the principles remain the same.   ;  Also one has to take care of the prerequisites of the collision detection and resolution. If the collision detection algorithm assumes that objects do not intersect initially, then the collision resolution has to be bullet proof in making sure that the are not intersecting  with any other object after the velocities have been updated.There are other things to take care of such as numerical errors. When checking for a collision you can run into problems if you just check whether the distance of two bodies is exactly zero, which is rarely the case. It is better to use some small value "epsilon" (e.g. epsilon = 1.0e-5, depending on scaling and whether you use floats or doubles) and check whether the absolute value of the distance is smaller than that.Some resolution algorithms are more fault tolerant and even allow intersections or small violation of constraints, e.g. Box2d (http://www.box2d.org), or IBDS (http://www.impulse-based.de/).   ;  As fng said, detecting a collision and reacting to it are two VERY different things, specially because reactions can be subject to the creativity of the game developer, while the detection itself tends to be more on the engine/framework side of the fence.There are many different collision detection systems that are best for different situations, for instance, the collision detection of a platformer game and a 1942 style shooter are radically different (if yo need to push performance as far as possible).If you want to solve the reaction side of the problem, by what you said it looks like you are aiming at simple physical body penetration prevention and some action/reaction force appliance. I would recommend trying out Box2D for this purpose, its a small popular and free phisics engine.The first mistake people make when implementing collision detection on their own is to assume once a collision is detected, a reaction must be performed.On the first place, when you are detecting collisions, you should check for all relevant objects and store a list of all the detected intersections if you want to create a response that makes sense.That way if your ball collided with two bodies in the same frame you could calculate the proper direction in which it should move away.As for "Moving the object back until it doesn't collide" this does not fix the problem, if an object was expected to move 1 meter, collided with something at 0.7 and stuck there, you just altered its speed, when instead it should have bounced and move another 0.3 in the corresponding direction (if the object is elastic).The object could also be a heavy rigid body falling to the ground and should stick or bounce very little, like I said, it is very application specific, so the Collision Detection System does not have the information to implement resolution, only inform of the existing detected collisions.In some cases you may also just want to know if a given object is inside a specific area, soy you may want to be informed of a "collision" but not move the object away from it.Hope this helps.