Hi Everyone.
I’m fairly sure that this what’s happening here is the way physics is supposed to work, but I was hoping someone might have an idea for a work around.
I have a crate object, which has physics body, bounce set to zero and friction to 1 etc.
The game starts, our crate is drawn at the top of the screen and it falls to the ground - no bounce - perfect!..However!
For this game, I will be adding a stack of these objects which will pile upon each other. Their fixedRotation is set to true so they wont fall over or anything, but because they’re all clones of the original crate, their densities and mass etc are all the same. I’m guessing that’s why when the crates hit each other, they’re bouncing slightly (the ones with a higher velocity ie, at the top, are bounding much higher than the rest)
Any ideas on how I might get the crates to stack up and not bounce at all?
Cheers in advance,
Michael Piercy
Pixel Wolf studios
**–EDIT–**
Here’s some code to help explain what I mean. Just need an image called crate.png with it.
[lua]–Require Physics
local physics = require (“physics”)
physics.start()
physics.setGravity(0, 25)
–Create Ground
myGround = display.newRect(0, display.contentHeight-50, display.contentWidth, 100)
physics.addBody(myGround, “static”, {bounce = 0.0, friction = 1.0})
–Function to Add a new crate - X and Y positions passed as parameters
function addCrate(xPos, yPos)
local thisCrate = display.newImageRect( “crate.png”, 64, 64 )
physics.addBody( thisCrate, “dynamic”, { density=1.0, friction=1.0, bounce=0.0 } )
thisCrate.isFixedRotation = true
thisCrate.x = xPos
thisCrate.y = yPos
return thisCrate
end
–Loop to add crates
for i = 1, 10 do
addCrate(200, -100*i)
end[/lua] [import]uid: 156990 topic_id: 29593 reply_id: 329593[/import]