Physics Objects with Bounce = 0, Still Bouncing. Any ideas?

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]

Hey there - is there any bounce on the ground? [import]uid: 52491 topic_id: 29593 reply_id: 118865[/import]

Hi Peach,

No there’s no bounce on the ground either. The first block lands solid without a bounce and looks fine. The next one lands on the first block and bounces just slightly, then the next bounces slightly more and more until the one at the top bounces high.

What do you reckon? [import]uid: 156990 topic_id: 29593 reply_id: 118869[/import]

I’ve updated the query with some code above. Hope this helps explain my problem a little better.
Thanks again for any help. [import]uid: 156990 topic_id: 29593 reply_id: 119003[/import]

I’m not seeing bounce with this but I’m seeing the bodies are intersecting when they shouldn’t be - and then moving outside of each other again.

Does that sound like what you’re seeing or are you getting actual bounce? (Just want to confirm.) What build are you using? [import]uid: 52491 topic_id: 29593 reply_id: 119020[/import]

No I don’t think it’s actually Bounce as such. It seems like the objects fall and intersect slightly and box2D retaliates by forcing them back out which essentially gives the impression of a bouncing chain reaction.

I have the objects set to bullets and even turning up the frame rate doesn’t help.

If I could manage to stop them from intersecting then I think that would solve it. But how?

I’ve checked it on public build as well as our latest subscription build. [import]uid: 156990 topic_id: 29593 reply_id: 119023[/import]

Well, def looks like you are running into the Box2d solver. From what I understand, isBullet is supposed to help with this very problem but it doesn’t seem to be having any affect. I’m kind of wondering if there is an issue there.

If you ramp up the setPositionIterations and setVelocityIterations it helps mitigate that effect but this comes at the cost of CPU usage.
[import]uid: 147305 topic_id: 29593 reply_id: 119068[/import]

Hi budershank, Thanks for the reply. Yeah I was thinking that isBullet wasn’t having any effect myself, but glad to hear someone else thinking the same.

I’ve tried your suggestions with of pumping up the position and velocity iterations, but it hasn’t affected the problem that I can see.

I really don’t want to have to turn gravity off and apply a constant force to each block intruded with collision listeners. Its a harsh workaround I think. [import]uid: 156990 topic_id: 29593 reply_id: 119112[/import]

I’m posting a reply so as to be subscribed to this thread. I’ve copied the code to play with, but have not figured out a fix. I’ll keep trying.

BTW, isn’t there a way to subscribe to a thread without posting? [import]uid: 23636 topic_id: 29593 reply_id: 119157[/import]

I am having similar issue.

Mine is two bodies joined by a weld. One of them is pulled by a touch joint. It goes through the floor! The one it’s welded to stays behind where it should.

Hmm… that gives me an idea- what if the touch joint attaches instead to ANOTHER body that is welded to the first? Then that new body will get pulled through but the others WONT because they’re under INDIRECT force rather than direct force from the touch joint. I think that just might work! yay! I will try this idea out forthwith. [import]uid: 63787 topic_id: 29593 reply_id: 128596[/import]

I am having similar issue.

Mine is two bodies joined by a weld. One of them is pulled by a touch joint. It goes through the floor! The one it’s welded to stays behind where it should.

Hmm… that gives me an idea- what if the touch joint attaches instead to ANOTHER body that is welded to the first? Then that new body will get pulled through but the others WONT because they’re under INDIRECT force rather than direct force from the touch joint. I think that just might work! yay! I will try this idea out forthwith. [import]uid: 63787 topic_id: 29593 reply_id: 128596[/import]