Bouncing ball never stops bouncing?

Hey
I have created a ball

[lua]–> ball stuff
local ballBody = { density=0.8, friction=0.3, bounce=0.8, radius=9 }
local ball = display.newImage(“gfx/ball.png”,180,50)
ball.linearDamping = 0.3
ball.angularDamping = 0.8
physics.addBody(ball, ballBody)[/lua]

I also have created a ground floor

[lua]local ground = display.newImage(“gfx/table.png”, true)
ground.y = display.contentHeight - ground.contentHeight/2
physics.addBody( ground, “static”, { friction = 1.0, bounce = 0.8, density = 1.0 } )[/lua]

I initiate the physics engine like this

[lua]–> Physics
local physics = require(“physics”)
physics.start()
physics.setGravity( 0, 9.81) – 9.81 m/s*s in the positive x direction
physics.setScale(200) – 200 pixels per meter[/lua]

The ball bounces perfect with respect to bounce and gravity BUT it never ends, it keep on bouncing forever.

Please help me stop him! [import]uid: 22737 topic_id: 6189 reply_id: 306189[/import]

I have never had a problem with that before, they physics engine should automatically make it bounce less each time, i think the problem has to be with the linear and angular bouncing, do you need this? i have never used it so i think this is the problem [import]uid: 19620 topic_id: 6189 reply_id: 21240[/import]

It seem to do with the ground being static, if I change it to dynamic the ball will stop to bounce. But how do I put a dynamic floor into my game without having the floor drop and disappear? [import]uid: 22737 topic_id: 6189 reply_id: 21241[/import]

Make sure to try taking out that dampening code, also your physics code NEEDS to be the first thing in your code, if its after your other code then it will not work [import]uid: 19620 topic_id: 6189 reply_id: 21243[/import]

Hey
Taking out the dampening code didn’t do it and the physics engine is at the top on my lua file but I pasted it last here, my bad.

What did the trick was to change the floor bodyType to dynamic then it stopped bouncing but then the floor have physics so it falls off the screen.

I placed a static floor 1 pixel height and 480 pixel wide and then I created the dynamic floor ontop of that static floor and it worked. But the problem that can occur on this solution is that the dynamic floor can sometimes bounce when the ball hits the floor and the floor bounces against the static 1 px line.

Any thoughts? [import]uid: 22737 topic_id: 6189 reply_id: 21393[/import]

ok well i tried your code, and at least the code that you posted was broken, you had your physics properties for the ball seperated in its own variable. this is how it should be

--\> Physics  
local physics = require("physics")  
physics.start()  
physics.setGravity( 0, 9.81) -- 9.81 m/s\*s in the positive x direction   
physics.setScale(200) -- 200 pixels per meter  
  
local ground = display.newImage("ground.png", true)  
ground.y = display.contentHeight - ground.contentHeight/2  
physics.addBody( ground, "static", { friction = 1.0, bounce = 0, density = 1.0 } )  
  
--\> ball stuff  
local ball = display.newImage("ball.png",180,50)  
physics.addBody(ball, {density=1.5, friction=0.3, bounce=0.4, radius = 9})  

anyways i still did come across your problem were the ball would not stop bouncing, i played around with some values and got it to work, try the above code it will work for you, the main problem was the bounce was just too high, once i lowered it, it seems to work fine. and the ground is a static object. try it out
[import]uid: 19620 topic_id: 6189 reply_id: 21426[/import]

Hey Madjack
As I wrote I just pasted the code in parts and not as a whole which was my bad, sorry for that. I have played with the values and when lowering the bounce factor there is no problem to make the ball stop bouncing but instead it does not bounce the way a ping pong ball does.

So there is a way of stopping the ball to bounce but still I can’t make it behave the way I need it to behave because when lowering the bounce it will not behave like a light ping pong ball but rather like a pool ball or something a lot heavier.

Thanks for you efforts Madjack [import]uid: 22737 topic_id: 6189 reply_id: 21429[/import]

Yea it seems to me that some things just are weird with the physics engine, i have a game where i jump my ball object into the air, and it works fine but everyone once and a while when i hit jump my ball flys like 12 times as high as it should, its just unexplained… so who knows… keep with it and i bet you can find just the right values to get what you want. Also mess with the “setscale” maybe the value of this is throwing things out of wack? anyways good luck! maybe someone else will have more insight, im just a noob =p [import]uid: 19620 topic_id: 6189 reply_id: 21435[/import]

It happened to me too, the ball never stops bouncing, anyone?
[import]uid: 12407 topic_id: 6189 reply_id: 22308[/import]

read the last posts, you need to adjust your bounce values to be lower, for whatever reason when they are too high, the ball will not stop bouncing. [import]uid: 19620 topic_id: 6189 reply_id: 22369[/import]

The problem is that if you lower the bounce value you would end up with a ball not behaving like a light ping pong ball but like a tennisball. The only solution I have found is that if you let the ball bounce on a dynamic ground it will stop bouncing like it should but not on a static ground.

So put a static ground first and then put a dynamic ground on top of that and let the ball bounce on the dynamic ground, then it will behave like it should.

A little more work but worth it. [import]uid: 22737 topic_id: 6189 reply_id: 22393[/import]

Thanks guys, I’ll try that.
[import]uid: 12407 topic_id: 6189 reply_id: 22409[/import]

set bounce to 1 instead of .8 [import]uid: 28068 topic_id: 6189 reply_id: 22501[/import]

I’ve tried to set bounce to 1 and it doesn’t work.
I’ve tried with the dynamic floor and it somewhat works, the problem is that as soon as the balls starts bouncing it moves the floor…
[import]uid: 12407 topic_id: 6189 reply_id: 22829[/import]

I put one small static line on top of the dynamic floor at the x=0 and at the x=480 or how your orientation is setup to hold down the floor.

I believe this has to a bug somewhere because it is a lot of work to get a small ball to bounce correct on a floor :slight_smile:
[import]uid: 22737 topic_id: 6189 reply_id: 22913[/import]

I tried with a big dynamic line on top of a smaller static line and so far it works. Although in some situations the ball goes thru the dynamic line, maybe because it’s just one pixel thick.
[import]uid: 12407 topic_id: 6189 reply_id: 23081[/import]

I hope Carlos or someone at Ansca can take that and answer. I have noticed this as well and it is very irritating. [import]uid: 22737 topic_id: 6189 reply_id: 23087[/import]

I arrived at this thread looking for why an object doesn’t stop bouncing. I am experiencing the same thing with some text that I have falling and just keeps on bouncing.

I found that a bounce of anything greater than .6 never stops.

Looks like a bug in the physics engine not rounding off the diminishing value to be less than a pixel so it just keeps bouncing. At some point the values should be rounded off to 0 and the object stops.

-Scott
[import]uid: 65977 topic_id: 6189 reply_id: 39112[/import]

instead of having a static ground below dynamic for support try “kinematic” bodytype
it interacts with and is affected by forces but gravity has no effect on it [import]uid: 43696 topic_id: 6189 reply_id: 39120[/import]

@ kofmes - Thanks for this, I have tried kinematic in the past and it works fine.

More people should reply to say things work so others can know, instead of guess as everyone else just stops nagging for an answer.

Sorry rant over! :o)

[import]uid: 26801 topic_id: 6189 reply_id: 40091[/import]