Can physics objects not be jello-like?

Is there some way to make a stack of physics objects NOT behave like jello?

No matter how I set the parameters a sizable stack becomes jello-like and it looks terrible! I’m making a “karate-like” game, where a stack of wood plates are to be cracked. These wood parts are made of two

objects that balances on one support each so that when the user hits them from above they “break”:

The physcal objects look like this:

And in the game it look like this (more or less)

Anyway, the problem is that when the physics are started, the stack “slumps down” and wobbles like the objects are made of nothing hard, but some kind of jello. This looks absolutely awful. In addition, the stacks are unstable and WILL fall down eventually.

Today I have to use a timer and start the physics right before the “hit” for the stacks not to fall down by themselves.

I’ve made a super simple example showing the jello problem:

local physics = require("physics") \_W = display.contentWidth \_H = display.contentHeight \_BOTTOM = \_H + (display.actualContentHeight - \_H)/2 physics.start() physics.setDrawMode("debug") --physics.setGravity(0,1); local ground = display.newRect(\_W/2, \_BOTTOM, \_W, \_H\*0.03) ground.anchorY = 1 physics.addBody(ground, "static") local brickHeight = \_H\*0.03 local brickList = {} for i=1,30 do -- Bricks local offsFromBotPart = \_BOTTOM - ground.height - (i-1) \* brickHeight brickList[i] = display.newRect(\_W\*0.5, offsFromBotPart, \_W\*0.1, brickHeight) brickList[i].anchorY = 1.0 physics.addBody(brickList[i], {density=1, friction=1.0, bounce=0.0}); end

Is this how is  must be with the physics engine? Or is there some trick that I do not know about?

Hi @runewinse,

Stacks of physical objects can spread thier inertia around to neighboring objects, resulting in the instability and “jello” type behavior. Fortunately, this can be controlled somewhat by the tactics outlined in the following tutorial:

https://coronalabs.com/blog/2015/03/03/tutorial-solutions-to-common-physics-issues/

Brent

Hi Brent,

Thanks for the tip. Increasing the linear/angular damping helps, but with a linear damping of about 1 it’s still looks like jello AND it ruins the effect when things are supposed to fall.

In short: It’s unfortunately doesn’t solve much.

Actually, just setting the gravity to (0, 4) both results in less jello effect and gives a more realistic movement when things are falling…

But a very relevant question: Can the linear damping be adjusted on the fly?

Before starting this thread, I tried the following to fix the jello-effect:

  1. I made all “destructible” bodies “static” except for the topmost. This made the “tower” completely stable.

  2. In the (first) collision event (between the karate body and the top “destructible”), I started a timer.performWithDelay(1, changeBodyType) where the changeBodyType() function changed all the rest of the “destructibles” from “static” to “dynamic”

This did not work particularly well…(nothing but the already “dynamic” body moved)

But would changing the linear damping work any better? Is this a parameter that is designed to be changed on the fly?

Turns out, setting the linear damping on the fly works much better than changing the object type!

So, in the end, this was a great tip, Brent! Thanks!

For gravity; why don’t you use Object.gravityScale = 0 Much more efficient.

Is setting the gravityScale property for all objects in the scene more efficient than setting the overall gravity once?

Not sure I’m following you.

Well kinda matter what kinda game your making… Your call.

Good Luck!

I’m struggling with this same issue using large stacks of bricks (50-100 high).  I’ve been playing with linear damping as I stack the bricks and it doesn’t seem to do much/anything to mitigate the “squishing” - can you describe your strategy for setting linear damping “on the fly” - are you changing the damping as a result of actions/events?  

If you can expand on your strategy in any way it would be much appreciated - I’m sick of jello bricks!  BTW, this is the code I’m running:

local building = display.newGroup(); local startPos = { x = 600, y = display.actualContentHeight - ground.height }; local curPos = { x = 600, y = display.actualContentHeight - ground.height }; for count = 1, 100, 1 do local newBrick = display.newImage(building, "brick.jpg", curPos.x, curPos.y ); physics.addBody(newBrick, "dynamic", { friction = .5, bounce = 0.0, density = .2, linearDamping = 10, angularDamping = 10 }); if count % 2 == 0 then curPos.x = startPos.x; if(count ~= 0) then curPos.y = curPos.y - newBrick.height; end else curPos.x = curPos.x + newBrick.width; end end

Yes, I set the linear damping as high as 100 when the bricks are created. Then, when the topmost brick is hit, I go through all of them and set the linear damping to 1. A more advanced variant would be to set the linear damping to 1 for the brick below at each colission event. So if you have this stack:

A

B

C

D

E

F

G

When A is hit (by anything) -> set the linear damping of B to 1

When B is hit (by anything) -> set the linear damping of C to 1

etc.

I don’t know if this would work, but if you have a tower of 100 bricks I’m fairly sure my simple method would not be enough to get rid of the jello-effect…

BTW: This is the game in which I use the technique:

https://play.google.com/store/apps/details?id=com.gmail.runewinse.Karate_Squid&hl=en

It’s a childs education game for learning to memorize foreign words, where the karate squid breaks through as many bricks as the player has correct words…

-Rune

Thanks for the feedback - I’ll try your solution out.

Your game looks great - I’ll have my 5 and 7 year olds try it out this afternoon.  They are both in immersion Spanish schools, this looks like a great way to learn new vocab.

Thanks, the app is mainly meant people who are trying to learn English as their second language, but it should work either way I guess. The only thing is that there is a feature where the secon language words are spoken and that would nok work well with spanish (when the text to speech engine tries to pronounce spanish words  :lol: ).

But the app is under constant development and I’ll probably add a “second language selection” very soon.

BTW: I’ve added Spanish (and a slew of other languages to the “foreign” language list) now (can be selected in “settings”).

Hi @runewinse,

Stacks of physical objects can spread thier inertia around to neighboring objects, resulting in the instability and “jello” type behavior. Fortunately, this can be controlled somewhat by the tactics outlined in the following tutorial:

https://coronalabs.com/blog/2015/03/03/tutorial-solutions-to-common-physics-issues/

Brent

Hi Brent,

Thanks for the tip. Increasing the linear/angular damping helps, but with a linear damping of about 1 it’s still looks like jello AND it ruins the effect when things are supposed to fall.

In short: It’s unfortunately doesn’t solve much.

Actually, just setting the gravity to (0, 4) both results in less jello effect and gives a more realistic movement when things are falling…

But a very relevant question: Can the linear damping be adjusted on the fly?

Before starting this thread, I tried the following to fix the jello-effect:

  1. I made all “destructible” bodies “static” except for the topmost. This made the “tower” completely stable.

  2. In the (first) collision event (between the karate body and the top “destructible”), I started a timer.performWithDelay(1, changeBodyType) where the changeBodyType() function changed all the rest of the “destructibles” from “static” to “dynamic”

This did not work particularly well…(nothing but the already “dynamic” body moved)

But would changing the linear damping work any better? Is this a parameter that is designed to be changed on the fly?

Turns out, setting the linear damping on the fly works much better than changing the object type!

So, in the end, this was a great tip, Brent! Thanks!

For gravity; why don’t you use Object.gravityScale = 0 Much more efficient.

Is setting the gravityScale property for all objects in the scene more efficient than setting the overall gravity once?

Not sure I’m following you.

Well kinda matter what kinda game your making… Your call.

Good Luck!

I’m struggling with this same issue using large stacks of bricks (50-100 high).  I’ve been playing with linear damping as I stack the bricks and it doesn’t seem to do much/anything to mitigate the “squishing” - can you describe your strategy for setting linear damping “on the fly” - are you changing the damping as a result of actions/events?  

If you can expand on your strategy in any way it would be much appreciated - I’m sick of jello bricks!  BTW, this is the code I’m running:

local building = display.newGroup(); local startPos = { x = 600, y = display.actualContentHeight - ground.height }; local curPos = { x = 600, y = display.actualContentHeight - ground.height }; for count = 1, 100, 1 do local newBrick = display.newImage(building, "brick.jpg", curPos.x, curPos.y ); physics.addBody(newBrick, "dynamic", { friction = .5, bounce = 0.0, density = .2, linearDamping = 10, angularDamping = 10 }); if count % 2 == 0 then curPos.x = startPos.x; if(count ~= 0) then curPos.y = curPos.y - newBrick.height; end else curPos.x = curPos.x + newBrick.width; end end

Yes, I set the linear damping as high as 100 when the bricks are created. Then, when the topmost brick is hit, I go through all of them and set the linear damping to 1. A more advanced variant would be to set the linear damping to 1 for the brick below at each colission event. So if you have this stack:

A

B

C

D

E

F

G

When A is hit (by anything) -> set the linear damping of B to 1

When B is hit (by anything) -> set the linear damping of C to 1

etc.

I don’t know if this would work, but if you have a tower of 100 bricks I’m fairly sure my simple method would not be enough to get rid of the jello-effect…

BTW: This is the game in which I use the technique:

https://play.google.com/store/apps/details?id=com.gmail.runewinse.Karate_Squid&hl=en

It’s a childs education game for learning to memorize foreign words, where the karate squid breaks through as many bricks as the player has correct words…

-Rune