# maintaining body separation (arcade physics)

## Recommended Posts

I have a scene where blocks fall from the sky onto the ground. As they do, they stack up thanks to collision separation. I noticed however that after the stack reaches a height of two or three blocks the incoming block somehow forces blocks at the bottom to lose their separation.

I want to stop that from happening. If two blocks collide they should remain separated.

I am using the arcade physics, (hope that's not the problem).

here is the code

##### Share on other sites

This same topic was covered recently however I can't seem to find the post. I'm pretty sure (correct me if I'm wrong here anyone who knows better) that Arcade physics is not really cut out for this kind of simulation. It has rudimentary separation logic which quickly gets confused by situations involving many collisions and nowhere for the colliding objects to go.

Arcade physics is meant to give you a very basic old-school approximation of physical forces, such as gravity, velocity and collisions, such as you'd find in your typical 8 and 16 bit platform games. It's very fast, and can calculate lots of collisions, but is not designed to do the kind of complex operations that people have come to expect from modern games (i.e. Angry Birds style physics).

I'd advise you to either work on some way to write some code to 'lock' objects in one or both axes when they are part of a stack, or if you need a more realistic and less arduous approach, use P2 for your physics calculations.

##### Share on other sites

I had thought of custom collision handling, but the problem is that by the time arcade calls your collision callback, it's too late, the body may already have overlapped, so if you 'lock' things, it starts to look a little weird.

I think you might be right but I'll leave this open until tomorrow incase someone finds a sneaky solution we haven't thought of.

##### Share on other sites

I think the problem is that Arcade's separation code simply tries to stop two objects intersecting by moving them apart. If you have say three objects all trying to de-intersect from one another, they're gonna start doing weird things and intersecting anyway. The objects never come to rest because they're constantly pushing away from one another. P2 and other advanced physics systems are kitted out to deal with exactly these kinds of situations.

Saying that, it would be nice if anyone's found an elegant way to tackle this!

##### Share on other sites

I just tried P2, and the results were MUCH better.

thanks lewster!