Consistent Object bounce? *RESOLVED BY MYSELF SO THERE :) **

I have question. I have ball. I have ground. I want ball to bounce on ground. I want ball to bounce on ground at the same height every time, no exceptions.

How can ball bounce like this?
Yes, I spoke very simply, imagine a russian accent lol. Basically, I want a ball, object whatever to bounce, but I want it to bounce up to a certain point and never go beyond that point every time. So first bounce it goes 2 foot high, second bounce it goes 2 foot high etc.
I have been messing with bounce, but I am not sure if this is the correct attribute or not?
**edit - I just did some reading that due to some numerical calculations in Box2d, this is hard to do. Talks about using linear dampening etc.

Anyone have any examples of this or know another way?

-Nick [import]uid: 61600 topic_id: 11733 reply_id: 311733[/import]

bounce = 0 in ground dont work? [import]uid: 23063 topic_id: 11733 reply_id: 42732[/import]

Nope.

I tried putting bounce just on the ball/object only and leaving everything else at 0. I’ve tried combinations of ground and object bounce settings.

Basically if I set bounce too high, the object will bounce a little higher and higher.

If I set bounce too low, then the object will bounce a little lower and lower each time. This is cool when I want to demonstrate how a ball would bounce in real life but since I am making a game, having the object bounce at the same height each time is a critical core part of my game.
Basically, If I can’t find a way (im experimenting like crazy right now) to make it work, I’ll have to scrap this project :frowning:

I’ve thought of implementing an alternate play style, but this is really something I want to work, badly.

*Edit -

I found this
“You may find that an object with a bounce set to exactly 1.0 will rebound somewhat higher than its original height, due to numerical approximations in Box2D. Bounce values slightly below 1.0, possibly combined with some linear damping, may be used for a closer simulation of “same height” behavior over short periods of time. Over long periods of time, it may be difficult to avoid runaway or decaying bounce.”

Source

http://developer.anscamobile.com/content/game-edition-physics-bodies [import]uid: 61600 topic_id: 11733 reply_id: 42739[/import]

@nicholasclay,
try to play with the friction value as well as the bounce on both the ground and the object before you venture into other things.

cheers,
?:slight_smile: [import]uid: 3826 topic_id: 11733 reply_id: 42758[/import]

Hey, it’s a physics engine. In the real world, bouncing objects lose energy and eventually stop bouncing. :slight_smile: I wonder if you could hack something to monitor/reset object.y when it tries to go below?

BTW, I did the Russian voice thing - hilarious! [import]uid: 58455 topic_id: 11733 reply_id: 42761[/import]

Ok, I think I am thinking about this incorrectly.
My goal is to make an object bounce, and be at the same height each and everytime.

I think what I should do is make an object JUMP and then apply force or whatever the term is to the object so it always jumps the same height no matter what and is on a loop.
…so now I have to find out how to have an object jump and be on a loop so it does it over and over again.
How the crap do I do that? …let the search begin! [import]uid: 61600 topic_id: 11733 reply_id: 42935[/import]

Ok I fixed it. You have to mess around with the density of the object. If the density is too high, then the bounce needs to be adjusted. I got it where it doesn’t vary too much and after about 20 minutes it’s still within a pixel or 2 which is good enough. If you change gravity, or add bounce to anything else you have to account for that too!

pain in my ass :slight_smile: but fun.

[code]
local physics = require (“physics”)
physics.start()
physics.setGravity(0,9.8)

ball = display.newImage (“ball.png”)
ball.x = 160
ball.y = 200

local ground = display.newImage( “ground.png” )
ground.x = display.contentWidth / 2 ground.y = 445
physics.addBody( ball, { density=1.0, friction=0.5, bounce=0.97} )
physics.addBody( ground, “static”, { friction=0.5, bounce=0 } )

[/code] [import]uid: 61600 topic_id: 11733 reply_id: 43295[/import]

I’m not sure whether or not to censor you on the word “ass”. The rules say no swearing, but I wrote them and I don’t THINK “ass” is a swear word… Here an “ass” is a donkey.

Well done on figuring it out, Nick :slight_smile:

Peach [import]uid: 52491 topic_id: 11733 reply_id: 43404[/import]

hmmm, censorship is a very funnything, I remember the internet filters that were for the three letter word that everyone is involved in but is a taboo, surprise!! the one that sounds like the number six…

so essex was blocked as it included the word, and many more innocent words that had nothing to do with the ulterior meaning had to be sacrificed and you can imagine when websites were blocked just for having that word, and not to mention the speed through the filters on a 48K dial-up speed on a supposedly 56K modem. Some might wonder what’s that, that was when you guys were still playing in kindy or so.

cheers,
:wink: [import]uid: 3826 topic_id: 11733 reply_id: 43409[/import]

Ok I fixed it. You have to mess around with the density of the object. If the density is too high, then the bounce needs to be adjusted. I got it where it doesn’t vary too much and after about 20 minutes it’s still within a pixel or 2 which is good enough. If you change gravity, or add bounce to anything else you have to account for that too!

pain in my BEEP :slight_smile: but fun.

[code]
local physics = require (“physics”)
physics.start()
physics.setGravity(0,9.8)

ball = display.newImage (“ball.png”)
ball.x = 160
ball.y = 200

local ground = display.newImage( “ground.png” )
ground.x = display.contentWidth / 2 ground.y = 445
physics.addBody( ball, { density=1.0, friction=0.5, bounce=0.97} )
physics.addBody( ground, “static”, { friction=0.5, bounce=0 } )

[/code] [import]uid: 61600 topic_id: 11733 reply_id: 43294[/import]

Ok I changed it to BEEP from that “other” word :slight_smile:

now it says “PAIN IN MY BEEP”
Hehe :slight_smile: [import]uid: 61600 topic_id: 11733 reply_id: 43427[/import]

Jayantv, don’t worry, it’ll never be like THAT :stuck_out_tongue: (I recall the tail end of that kind of censorship, and “56k” modems ;))

Nick, you didn’t need to change it - I was just teasing. Really unless it’s a “real” swear it’s not going anywhere and even that is just to keep the forum safe for all ages. (A few young’uns around since Bubble Ball.)

[import]uid: 52491 topic_id: 11733 reply_id: 43531[/import]

lol, I recall 300 baud modems.
you could physically watch the ascii appear, like interlaced images on ‘slow’ connections there days.

Ah.

And I’m 28 :confused: Thats how much of a geek I always have been.
[import]uid: 34945 topic_id: 11733 reply_id: 49301[/import]

So to rehash an older thread.

The marvelous renvis@technowand has a better (more consistent) solution.

This code is a go through platform (doodlejump type game) but the constant bouncing is what I REALLY REALLY like.

[code]
local physics = require(“physics”)
physics.start()
physics.setGravity(0,9.8)

local jumpPlatform = display.newRect( 120, 250, 60, 5 )
physics.addBody( jumpPlatform, “static”, { friction=0.3 } )
jumpPlatform.isSensor = false

local jumpPlatformbottom = display.newRect( 120, 256, 60, 5 )
physics.addBody( jumpPlatformbottom, “static”, { friction=0.3 } )
jumpPlatformbottom.isSensor = true

local function onFloorCollision( event )
if event.phase == “ended” then
jumpPlatform.isSensor = false
end
end

local function onFloorBottomCollision( event )
jumpPlatform.isSensor = true
end

jumpPlatformbottom:addEventListener( “collision”, onFloorBottomCollision )
jumpPlatform:addEventListener( “collision”, onFloorCollision )

–ball coming from bottom
—[[
local ball = display.newCircle(150,350,10)
physics.addBody( ball, “dynamic”, { friction=0.3,density = .2,bounce = 0.5 } )
ball:applyLinearImpulse(0, -1, ball.x, ball.y)
–]]

–ball coming from top
–[[
local ball = display.newCircle(150,150,10)
physics.addBody( ball, “dynamic”, { friction=0.3,density = .2,bounce = 0.5 } )
ball:applyLinearImpulse(0, 1, ball.x, ball.y)
–]]
[/code] [import]uid: 61600 topic_id: 11733 reply_id: 56967[/import]