how to stack physics boxes without compression?

My code is dropping a series of boxes on top of each other into a stack, and after the first couple boxes the stack compresses considerably with each new box. Is there a way to setup the physics so that the stack won’t compress?

Here is a snippet of code that shows what I’m talking about:

[code]
local physics = require(“physics”)
physics.start()
physics.setGravity(0, 15)
physics.setScale(90)

local floor = display.newRect(0, 420, 320, 20)
physics.addBody(floor, “static”, {bounce = 0})

local function drop(event)
block = display.newRoundedRect(120, 20, 46, 46, 7)
block:setFillColor(0, 0, 200)

local inset = 22
local shape = {-inset,-inset, inset,-inset, inset,inset, -inset,inset}
physics.addBody(block, {bounce = 0, shape = shape})
block.isFixedRotation = true
block.isBullet = true
end

timer.performWithDelay(2000, drop, 0)
[/code] [import]uid: 12108 topic_id: 4669 reply_id: 304669[/import]

Your gravity seems to be quite high, also you could try setting the density to be a low value. Also, maybe have a pre-collision handler and when that fires, kill the linear velocity, then remove the collision handler?

I’ve not tried it; just some ideas.

matt.

ps: When I write handler, I mean listener function. Sorry, I work in other languages a lot. [import]uid: 8271 topic_id: 4669 reply_id: 14781[/import]

I think I’ve tried low density before but I’ll try that again to be sure. That idea about the pre-collision listener is a clever idea, I’ll give that a shot.

Is that really such high gravity? I mean, default gravity is 10 and I’m pretty sure there’s the compression problem just leaving gravity at default. [import]uid: 12108 topic_id: 4669 reply_id: 14833[/import]

Probably not with the gravity, tbh, but I’ve got a similar thing going on in my game and I considered having all the blocks as a single graphic and converting them when it landed. Went the multiple blocks route and just the linearDamping.

Let us know how you get on - it’s valuable research, IMHO.

matt. [import]uid: 8271 topic_id: 4669 reply_id: 14846[/import]