Real Gravity and stopping bouncing

Hi,

I have a game atm, everything is almost working right although I just can’t get the gravity correct.

  1. At the top my character seems to float then come down a bit slow

  2. When my character hits the floor they bounce a bit, I thought that bounce=0 should stop this???

I have the following settings throughout my code:

local borderBody = { density=1, friction=0, bounce=0 }

physics.setGravity(0,30)

physics.addBody( floor, “static”, borderBody )

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

I know I have the gravity set quite high but if its set to 9.8 as I said he just floats.

Any help would be appreciated.

Thanks

Kevin

I created a new physics project, which made the template game with a falling crate.

Changed these 3 lines:

  1. commented this one out:

    –crate.rotation = 15  

  2. changed bounce to 0.0 here:

    physics.addBody( crate, { density=1.0, friction=0.3, bounce=0.0 } )  

  3. added bounce=0.0 here:

    physics.addBody( grass, “static”, { friction=0.3, shape=grassShape, bounce=0.0 } )  

The crate doesn’t seem to bounce anymore.

Try doing same, and see if it work in your game

Hi Kevin,

As @mildspringllc suggests, set the bounce of both objects (character and floor) to 0 to prevent bouncing. A level of bounce on either one will result in some restitution, so you need to negate it completely with 0 on both of them.

Brent

Hi,

Thanks for the responses - I think I have this fixed, I didn’t put a width or height in to the config and everything was really small (really high resolution) at this point even though I had both items as bounce 0 it was still bouncing - i’ve now put 320 by 480 in for the width and  height - had to make a few changes with positioning of my items and image sizes etc but soon as I did that the gravity now looks real and the bouncing has completely stopped so must of been something to do with that.

Thanks for your help though - at least it confirmed what i had was correct.

Thanks

Kevin

I created a new physics project, which made the template game with a falling crate.

Changed these 3 lines:

  1. commented this one out:

    –crate.rotation = 15  

  2. changed bounce to 0.0 here:

    physics.addBody( crate, { density=1.0, friction=0.3, bounce=0.0 } )  

  3. added bounce=0.0 here:

    physics.addBody( grass, “static”, { friction=0.3, shape=grassShape, bounce=0.0 } )  

The crate doesn’t seem to bounce anymore.

Try doing same, and see if it work in your game

Hi Kevin,

As @mildspringllc suggests, set the bounce of both objects (character and floor) to 0 to prevent bouncing. A level of bounce on either one will result in some restitution, so you need to negate it completely with 0 on both of them.

Brent

Hi,

Thanks for the responses - I think I have this fixed, I didn’t put a width or height in to the config and everything was really small (really high resolution) at this point even though I had both items as bounce 0 it was still bouncing - i’ve now put 320 by 480 in for the width and  height - had to make a few changes with positioning of my items and image sizes etc but soon as I did that the gravity now looks real and the bouncing has completely stopped so must of been something to do with that.

Thanks for your help though - at least it confirmed what i had was correct.

Thanks

Kevin