Object squeezed

Topics: User Forum
Feb 1, 2012 at 5:29 PM

If a player pushes against a wall the wall won't move and neither will the player (as per Newton's third law of motion). In the same way box B would not "enter" C if C is a static body (static in the Farseer sense). And A will not enter B - they will just get stuck to each other. That might actually be what you need.

Anyways in the general case you should check that B has collided with C and then check if A collides with B so as to cancel the forces acting on A.

Feb 1, 2012 at 6:46 PM

Let's say you have gravity and B is resting on C.  Then the contact force impulse calculated by the engine and given to you in the callback will be the expression of the weight (G=mass*gravity) of B over the timestep. Even though B and C are touching they won't move since the force is not enough to "lift" B nor to "sink" C - again Newton's third law of motion - in reality the objects deform slightly but since here we deal with rigid bodies it's as if the forces cancel each other.

Now if you push on top of B then in your contact handler you'll get a bigger impulse equal to the "push" force + B's weight. If then there is a contact between B and Actor A (and you have detected that the impulse between B and C is bigger that simply the weight of B hence something must be acting on B in addition to gravity) then you can cancel the force produced by A since he's responsible.  Same story for lateral movement only gravity doesn't participate (or same for world with no gravity).

Would that work for you? Try logging the actual values you get in the contact callback to see. In a few words what I'm trying to suggest is to look at the magnitudes of the impulses and not just the simple collision yes/no. Some things are still unclear though - why does B "enter" C - they should not overlap, there's something fishy and this invalidates the whole physics argument. If B is "stuck" and I apply a force to it I should get in the contact the exact opposite impulse (so in fact they cancel and B and C are stationary).

Feb 1, 2012 at 7:36 PM

Won't it be easier to convert body A into a dynamic object and not kinematic since kinematic objects have infinite mass and therefore generate infinite forces thus interfere with the physics causing exactly what you observe - bodies passing through each other.

Feb 1, 2012 at 8:08 PM

I think the spring (distance joint I assume) will become unstable and will accumulate a lot of force but in principle it will work.