[Help] Small boucing but bounce = 0

Hello.

I have this scene:

1- A floor (static, bounce = 0, friction = 0)

2- Gravity (0,9.8) default

3- 4 Squares falling from the sky (dynamics, bounce = 0, friction = 0)

4- The squares spawn with 500ms delay between each other and fall to the same destination. Like a stack.

Even with bounce = 0, when one square colide with another one, they simulate a very small bounce. 

How do I remove this annoying small bounce everytime one square fall from the sky and collide with another one already in the ground?

Thank you so much

Show your actual code or provide a link to your project for us to download and examine it.

Likely there is a  typo or similar error, but w/o code we can’t fully advise.

PS - Just in case, when posting code:

formatyourcode.jpg

Could you post a video of this as well? Just so we can see how the bounce appears.

Here’s a project I found on my computer.

Is the bounce you said that was happening similar to the one in this project? If so, that’s barely noticeable. Yeah, it’s squishing.

@ponto

It occurs to me that you may actually be talking about squishing.

If you’re trying to create a stacking game, you will get some squishing for small parts/blocks.  

This is an unfortunate fact of life with Box2D.

@everyone,

Anyone out there made a stacker where they solved this problem?  Care to share your thoughts?

This is what I’m talking about:

https://www.youtube.com/watch?v=YHXS5-2rDYM&feature=youtu.be

local centerX = display.contentCenterX local centerY = display.contentCenterY local fullw = display.actualContentWidth local fullh = display.actualContentHeight local physics = require "physics" physics.start() physics.setGravity(0,9.8) physics.setDrawMode("hybrid") local group = display.newGroup() local maxOffset = 10 local ground = display.newRect( group, centerX, centerY + fullh/2 - 100, fullw, 40 ) ground:setFillColor(0,1,0) ground.alpha = 0.5 physics.addBody( ground, "static", { bounce = 0, friction = 1 } ) local function makeBlock() local block = display.newRect( group, centerX, centerY - fullh/2, 60, 60 ) if(maxOffset \> 0) then block.x = block.x + math.random(-maxOffset, maxOffset) end block:setFillColor(1,1,0) block.alpha = 0.5 physics.addBody( block, "dynamic", { bounce = 0, density = 1, friction = 1 } ) block.linearDamping = 0.25 end timer.performWithDelay( 750, makeBlock, -1)
local physics = require ("physics") physics.start() physics.setGravity(0,9.8) local imgTerreo local tableBlocos = {} imgTerreo = display.newRect(display.contentCenterX, display.contentHeight\*1, display.contentWidth, display.contentHeight\*0.2) imgTerreo:setFillColor(1,1,1) physics.addBody( imgTerreo, "static", { bounce=0, friction=0}) local function squares() local pos = table.getn(tableBlocos) + 1 tableBlocos[pos] = display.newRect(display.contentCenterX, display.contentCenterY, 100, 100) physics.addBody( tableBlocos[pos], "dynamic", { bounce=0, friction=0}) tableBlocos[pos].isFixedRotation = true end timer.performWithDelay( 800, squares, 4 )  

Well this is my code.

What I really feel is that my squares when they fall on top of each other, look like jellies.

There is no way (that i know of) to avoid that if you’re going to use physics bodies.

Ohhh I see.

Well, I ll try find other way then.

Thanks

There might be a way. Consider these options:

  1. Use a pre-collision listener only on the falling box… this is because pre-collision detection is very “noisy” and can generate hundreds of responses in a few milliseconds of time, hogging up resources, so you don’t want to use them too much (or needlessly). Anyway, when you get the first pre-collision response, remove the pre-collision listener (so that you don’t get more responses) and set the box’s linear velocity to (0,0), effectively stopping it very suddenly. That might help prevent it from sending its physical impulse/force onward to the existing stack of boxes (but you would of course need to experiment with this).

  2. When a box starts to fall, add a touch joint to it. Then, when it collides with the stack, set the joint’s “target” to the exact x/y location of the box (its own position). Also make sure the touch joint is set to be an instantaneous pull/set, not like a rubber band, since the idea here is to “snap” the box to its own x/y and thus hopefully prevent a bunch of force/impulse transmitting onward into the stack. Note that you also must create the joint in advance (box falling) because you can’t create new joints in the exact same time step as a collision.

No guarantees that these ideas will solve it, but it’s worth a shot!

Brent

Thank you sir, I ll try and let the thread know if worked.

@pontobarraGAME

The jelly-like quality is the blocks penetrating into each other because they are moving faster than the physics engine is accounting for their movement.  Box2D then rectifies the overlapping objects by adjusting their positions and you get the “jelly”.

Try:

[lua]block.isBullet = true[/lua]

this will force the physics engine to account for the block’s position every frame.

Also, make the object denser and ramp up the damping.

[lua]

physics.addBody( block, “dynamic”, { bounce = 0, density = 3, friction = 1 } )

block.linearDamping = 1

block.angularDamping = 20[/lua]

I ran your simulation with these changes and got better results

*Note*

This setting is computationally expensive and will slow down your game if the number of blocks gets too large.

[lua]block.isBullet = true[/lua]

As @sporkfin says, that property can affect performance. Fortunately for your situation, I think you could set it just for the falling block, and then after the collision essentially is resolved, set the property back to false (that way, all blocks are not using this extra detection method).

Brent

Show your actual code or provide a link to your project for us to download and examine it.

Likely there is a  typo or similar error, but w/o code we can’t fully advise.

PS - Just in case, when posting code:

formatyourcode.jpg

Could you post a video of this as well? Just so we can see how the bounce appears.

Here’s a project I found on my computer.

Is the bounce you said that was happening similar to the one in this project? If so, that’s barely noticeable. Yeah, it’s squishing.

@ponto

It occurs to me that you may actually be talking about squishing.

If you’re trying to create a stacking game, you will get some squishing for small parts/blocks.  

This is an unfortunate fact of life with Box2D.

@everyone,

Anyone out there made a stacker where they solved this problem?  Care to share your thoughts?

This is what I’m talking about:

https://www.youtube.com/watch?v=YHXS5-2rDYM&feature=youtu.be

local centerX = display.contentCenterX local centerY = display.contentCenterY local fullw = display.actualContentWidth local fullh = display.actualContentHeight local physics = require "physics" physics.start() physics.setGravity(0,9.8) physics.setDrawMode("hybrid") local group = display.newGroup() local maxOffset = 10 local ground = display.newRect( group, centerX, centerY + fullh/2 - 100, fullw, 40 ) ground:setFillColor(0,1,0) ground.alpha = 0.5 physics.addBody( ground, "static", { bounce = 0, friction = 1 } ) local function makeBlock() local block = display.newRect( group, centerX, centerY - fullh/2, 60, 60 ) if(maxOffset \> 0) then block.x = block.x + math.random(-maxOffset, maxOffset) end block:setFillColor(1,1,0) block.alpha = 0.5 physics.addBody( block, "dynamic", { bounce = 0, density = 1, friction = 1 } ) block.linearDamping = 0.25 end timer.performWithDelay( 750, makeBlock, -1)
local physics = require ("physics") physics.start() physics.setGravity(0,9.8) local imgTerreo local tableBlocos = {} imgTerreo = display.newRect(display.contentCenterX, display.contentHeight\*1, display.contentWidth, display.contentHeight\*0.2) imgTerreo:setFillColor(1,1,1) physics.addBody( imgTerreo, "static", { bounce=0, friction=0}) local function squares() local pos = table.getn(tableBlocos) + 1 tableBlocos[pos] = display.newRect(display.contentCenterX, display.contentCenterY, 100, 100) physics.addBody( tableBlocos[pos], "dynamic", { bounce=0, friction=0}) tableBlocos[pos].isFixedRotation = true end timer.performWithDelay( 800, squares, 4 )  

Well this is my code.

What I really feel is that my squares when they fall on top of each other, look like jellies.