Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have created a bouncing ball simulator using XNA and I am happy with my use of gravity, acceleration, change of direction and friction/spin.

However, I am now at a stage where I would like to define my ball as being made of a different material, subsequently meaning that the "bounce height" will be different depending on the elasticity of the material.

Ultimately, I will also want differing types of bounce surfaces as well. This will mean that I could have bounces as varied as:

  • Rubber ball on concrete.
  • Ping-pong ball on wood.
  • Concrete ball on mud.
  • Etc., etc.

My question is; How should I alter my bounce height depending on the material(s)?

I have found some information about Young's Modulus of Elasticity but I would be grateful if someone could advise as to how I use this (or another) value as a ratio in my "bounce" calculation.

Thanks in advance and please let me know if you would like to know anything else.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

The bounce is implemented by inverting the Y component of velocity, when the ball collides with the ground.

Ball.Velocity.Y *= -1 * COEFF;

If the COEFF is 1, the ball will have a "perfect" bounce, i.e. no energy will be lost. If COEFF is 0, the ball won't bounce at all. Put a fractional value between 0 and 1 in COEFF to get a realistic bounce.

Now you want to implement two "materials". So you could have two coefficients and calculate COEFF as follows:

COEFF = BALL_COEFF * SURFACE_COEFF

share|improve this answer
    
+1 beat me to it plus a fairly good approximation towards how things are commonly done to achieve that effect. –  teodron May 9 '12 at 11:12
    
I would expand on this and say that the angle of the bounce leaving is equal to the angle of the ball coming in relative to the tangent of the point of impact. This way, he could have balls bouncing off the walls or off of irregularly shaped objects and have balls bouncing off of other balls as well (though that one would really be a momentum conservation calculation). Inverting the Y velocity only works going up and down, what if he hits a 45 degree slope coming at a 70 degree angle, it would be vastly different result than coming down at a flat surface –  Azaral May 9 '12 at 11:33
    
I've got the Y inversion working fine, when angled surfaces and trajectories are involved. The use of a material coefficient seems like a good answer to my question. How would I determine the coefficients to use? Would it just be a case of testing? Or is there something predefined that I can use (maybe linking to the elasticity ratings for example)? –  Ste May 9 '12 at 11:53
    
Personally, I would recommend trying out values and finally selecting what "feels right". –  ApoorvaJ May 9 '12 at 12:17
4  
And if COEFF is greater than 1 you have Flubber. –  DampeS8N May 9 '12 at 12:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.