Physics - Stack of blocks topples

I’m fooling around with the physics engine a bit. I’m trying to place 12 blocks in a stack, but after a while (15 seconds or so) it topples over:

local physics = require("physics") physics.start() local w = display.contentWidth local h = display.contentHeight -- Ground local ground = display.newRect(w/2,h-30,w,30) physics.addBody(ground, "static", { density=5.0, friction=0.3, bounce=0.2}) -- Blocks for i = 0, 12 do     local block = display.newRect(w - 100, h - 75 - i\*50, 50, 50)     physics.addBody(block, "dynamic", { density=2.0, friction=0.9, bounce=0.0}) end 

I guess this is quite realistic as it would surely do this in real life with small inaccuracies, wind etc.

My question is this: Is there any way to control this “realism”? What if I actually wanted  these blocks to stay put until knocked down by a bird or something original?

You could make the blocks static until something hits one of them, then change them all to dynamic. 

That was a good tip!

Alternatively, do what you’d do in real life – stack lighter boxes on top:

for i = 1, 13 do local block = display.newRect(w - 100, h - 75 - i\*50, 50, 50) physics.addBody(block, "dynamic", { density=2/i, friction=0.9, bounce=0.0}) end

Is this what is being done in the real world? On a ship I guess thery would stack the lighter containers on the top, but do they care about this in the container terminal for instance? I haven’t really thought about this before now…

Anyway: Thanks for the tip  :slight_smile:

Well, that’s what I would do in real life but I can not vouch for others. Next time I’m in an airport, I will keep an eye out for vertical stacks of 12+ suitcases and attempt to weigh each one :wink:

Hehe - You’ll end up in jail for sure  :lol:

You could make the blocks static until something hits one of them, then change them all to dynamic. 

That was a good tip!

Alternatively, do what you’d do in real life – stack lighter boxes on top:

for i = 1, 13 do local block = display.newRect(w - 100, h - 75 - i\*50, 50, 50) physics.addBody(block, "dynamic", { density=2/i, friction=0.9, bounce=0.0}) end

Is this what is being done in the real world? On a ship I guess thery would stack the lighter containers on the top, but do they care about this in the container terminal for instance? I haven’t really thought about this before now…

Anyway: Thanks for the tip  :slight_smile:

Well, that’s what I would do in real life but I can not vouch for others. Next time I’m in an airport, I will keep an eye out for vertical stacks of 12+ suitcases and attempt to weigh each one :wink:

Hehe - You’ll end up in jail for sure  :lol: