[Help] Small boucing but bounce = 0

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