Game Development Community

Bouncing Ball - Help needed please

by Scott Wilson-Billing · in iTorque 2D · 09/01/2011 (5:45 am) · 10 replies

I'm needing to implement bouncing balls - the weight of the ball (various) will determine the bounce. I also want the ground to have an influence on the bounce e.g. ball bouncing on concrete will be different to grass.

Can somebody point me in the right direction please - I know how to create sprites etc etc, just need to know those magic physic parameters to play around with :)

Cheers
Scott

#1
09/01/2011 (6:53 am)
I created a good game with balls that bounce, in a way. Basically it was playing with all parameters to suit your desired effect. So, things like mass, density, friction, but also constantForceY(if that is how you are applying gravity). In terms of bouncing off the ground, CollisionResponseMode is huge for both ground and ball.
#2
09/01/2011 (7:14 am)
Yeah, just enable physics for an object (it defaults to off in iT2D), and you should have balls bouncing. One of the earlier example projects in iT2D is even a bunch of bouncing balls. Check your account for 1.3 or older.
#3
09/01/2011 (7:26 am)
Thanks Guys.

I'm looking to have a ball bounce, bounce again etc with each bounce height getting smaller as impact, friction, loss of momentum take effect. Is this achievable "out of the box".

I did try the bb tutorial but they just bounce off and keep going.
#4
09/01/2011 (9:27 am)
Did you set up world limits in any way? Default for levels is to have an infinite area to play around in.
#5
09/01/2011 (9:35 am)
I would think it is achievable. I am developing a fairly complex game in regards to the out of the box use of physics. I have no complaints beyond that I had it working perfectly, then I dramatically increased the size of the ball and lost the gravitational effects I had. I imagine if I keep fiddling with the settings I will get it tho.


#6
09/01/2011 (9:09 pm)
Scott see if this bounce works for you. This is the sprite object I used for one of my games to get a bouncing effect. Just place a floor and set the collision to clamp on the floor to test.

new t2dStaticSprite(bounceObject) {
      imageMap = "pegImageMap"; //change this to your imageMap
      frame = "0";
      canSaveDynamicFields = "1";
      useMouseEvents = "1";
      Position = "-3.296 -44.551";
      size = "5.557 5.403";
      Layer = "3";
      GraphGroup = "10";
      CollisionActiveSend = "1";
      CollisionPhysicsReceive = "0";
      CollisionDetectionMode = "CIRCLE";
      CollisionResponseMode = "BOUNCE";
      CollisionCircleSuperscribed = "0";
      ConstantForce = "0.000 2.500";
      ConstantForceGravitic = "1";
      ForceScale = "40";
      Restitution = "0.85";
      LinearVelocity = "0.000 10.000";
         mountID = "15";
   };
#7
09/01/2011 (11:34 pm)
Thanks Johnny, just what I was looking for :) Will try this weekend and report back.
#8
09/02/2011 (12:36 pm)
Don't forget about the damping property on each object, which will force a velocity slow down. It is very powerful so you will not need high values. I'm using that for my ball's rolling behavior.
#9
09/02/2011 (12:43 pm)
@Michael,
Regarding things like mass, density, damping, friction etc, things that may come into being a factor in how a ball is affected by gravity... what are the number settings? Is each one, any number??? or are any of them only between 0 and 1?


#10
09/02/2011 (1:04 pm)
Thanks Michael, I will definitely be needing damping as I want the ball to roll to a stop.