This project has moved. For the latest updates, please go here.

Static Bounce

Topics: Developer Forum, User Forum
Mar 5, 2010 at 8:40 AM
Edited Mar 5, 2010 at 10:48 AM

Hey all!

Im trying to make a bouncing game.

What I want to achieve is to have different platforms achieve a set amount of bounce, so even if you hit it from max height or minimum height it will always return the same amount of bounce. How can I do this?


I have looked at the rectangleGeom.RestitutionCoefficient = 1f;

but that is affected by the height you fall from. I don't want that. I want a static bounce height.



Mar 5, 2010 at 4:35 PM

I think that you're thinking about it in the wrong sense. Instead of thinking about having different values for each body, think of each platform as an object with different bounce properties. Just add a property to your platform class and in the OnCollide for the ball or player, if they hit a platform apply an impulse to the ball/player equal to the platform's bounce.


/* Psuedo code Incoming */
public class Platform
	public Vector2 BounceForce { get; set; }

public void OnCollide (Platform platform)
	ball.ApplyImpulse (platform.BounceForce);




Mar 6, 2010 at 12:50 AM

Oh ok, thanks for your suggestion. Is there some sample code on object classes that provides the OnCollide already integrated?