Stacking lots of dynamic objects

I have a loop that builds 2 stacks of 50 bricks each on top of each other.  I want these bricks to be dynamic because I’m going to be knocking them over and I want to see them collide with each other.  

The problem I’m having is that when I run this, the bricks initially compress - they act as if they are somewhat squishy, rather than completely rigid, and so the stacks bow out and collapse.  If I decrease the number of objects I’m stacking to 10, they stay put (but still seem to squish together initially before expanding again).

How can I pile up large numbers of dynamic objects without this effect?

local building = display.newGroup(); local startPos = { x = 600, y = display.actualContentHeight - ground.height }; local curPos = { x = 600, y = display.actualContentHeight - ground.height }; for count = 1, 100, 1 do local newBrick = display.newImage(building, "brick.jpg", curPos.x, curPos.y ); physics.addBody(newBrick, "static", { friction = 10, bounce = 0.0, density = .2 }); if count % 2 == 0 then curPos.x = startPos.x; if(count ~= 0) then curPos.y = curPos.y - newBrick.height; end else curPos.x = curPos.x + newBrick.width; end end

Hi @aaron4,

This behavior is caused because, when you stack a ton of objects on each other, the physics engine has to “transmit energy” from block to block, and it sort of makes the entire constuction a bit unstable (hence the squishy or “jello” effect).

Fortunately, there are workarounds for this. Some of them are described in this tutorial:

http://coronalabs.com/blog/2015/03/03/tutorial-solutions-to-common-physics-issues/

Another user recently had the same issue, and he solved it (if I recall) by increasing the linear/angular damping on the objects until the exact point when he wanted the structure to be prone to collapsing (at which point he “reset” the damping to standard levels. So that is another option if you want to experiment with it.

Best regards,

Brent

There was a recent discussion on the same topic here:

https://forums.coronalabs.com/topic/59280-can-physics-objects-not-be-jello-like/#entry306861

Thanks guys - both of those articles are helpful.  I had seen the one from Brent but not the one from roaminggamer - I’ll play around with that strategy and see what happens.

Thanks again!

Hi @aaron4,

This behavior is caused because, when you stack a ton of objects on each other, the physics engine has to “transmit energy” from block to block, and it sort of makes the entire constuction a bit unstable (hence the squishy or “jello” effect).

Fortunately, there are workarounds for this. Some of them are described in this tutorial:

http://coronalabs.com/blog/2015/03/03/tutorial-solutions-to-common-physics-issues/

Another user recently had the same issue, and he solved it (if I recall) by increasing the linear/angular damping on the objects until the exact point when he wanted the structure to be prone to collapsing (at which point he “reset” the damping to standard levels. So that is another option if you want to experiment with it.

Best regards,

Brent

There was a recent discussion on the same topic here:

https://forums.coronalabs.com/topic/59280-can-physics-objects-not-be-jello-like/#entry306861

Thanks guys - both of those articles are helpful.  I had seen the one from Brent but not the one from roaminggamer - I’ll play around with that strategy and see what happens.

Thanks again!