Is there a way to set bounciness > 1?

I’m trying to make something a little like those round bouncers in pinball - I want an object to collide with this and to bounce off of it with an additional boost, faster than it was moving before the collision. The easiest way I can think of to do this is to set a bounciness greater than one.

If I can’t make that work, the only way I can think of is to make it a trigger and calculate normal, angle, and set velocity manually. Which you’re not supposed to do with a physics object. Are there any better methods that someone could suggest?

Says who? :wink: Seriously, no reason not to. I doubt you’d have to calculate all that, though…just use OnCollisionEnter to increase the velocity, since when that fires, the object has already hit and rebounded.

–Eric

Thanks. This is… mostly working for me, but it’s a little funky. When I use OnCollisionEnter with moving spheres and a stationary bounce cylinder, using the below script, I get the desired behavior a good portion of the time, but sometimes the spheres slow down instead of speeding up. My suspicion is that OnCollisionEnter isn’t always taking place after the bounce, so the impulse is being applied to the incoming velocity instead of the outgoing velocity.

I tried using OnCollisionExit instead, but that just seems to make it worse. Sometimes, if I’m using OnCollisionExit, I’ll get a sort of “sticking” behavior, where the spheres sit on the surface of the cylinder, sliding around it before flying off again.

Is there a way to tell exactly which action is being performed when?

public class KickBounce : MonoBehaviour {

	public float kickStrength = 1.0f;

	void OnCollisionEnter(Collision collision) {

		ContactPoint contact = collision.contacts[0];
		Rigidbody otherRigidbody = collision.rigidbody;

		otherRigidbody.AddForce(-contact.normal * kickStrength, ForceMode.Impulse);
}
}

Try printing the velocity in OnCollisionEnter and see if it’s what you expect.

–Eric

Well, just to report back: I figured out that the problem I was having was related to fixing the position of the cylinder, not to the timing of OnCollisionEnter. When I remove the rigidbody from the cylinder, or I don’t fix its position and just let it bounce around everything works fine.

I’m not sure how I’m going to integrate that into my game, since I want it to move but not to be moved by collisions, but I’ll figure that out. At least I know how to approach it now, thanks.