In 3D physics materials, we have the setting of ‘Bounce Combine’ which dictates how the two physics materials bounciness values combine together to determine the overall bounce of the collision.
The choices are Average (of the two bounciness values), Minimum, Maximum, and Multiply which just multiplies the bounciness values together
Multiply is the mode I really want, but this setting of ‘Bounce Combine’ is just not available at all for 2D Physics materials, and the way it works by default is the equivalent of ‘Maximum’ in 3D.
One thing I tried to get multiplicative bounce was setting physics materials bounciness to 0 and instead use my own Bounce code:
void OnCollisionEnter2D(Collision2D collision)
{
float multipliedBounce = bounciness * collision.otherRigidbody.GetComponent<Phys>().bounciness;
foreach (ContactPoint2D contact in collision.contacts)
{
Vector2 impactVelocity = contact.relativeVelocity;
float velocityInNormalDirection = Vector2.Dot(impactVelocity, contact.normal);
Vector2 force = contact.normal * velocityInNormalDirection * rb.mass * multipliedBounce;
rb.AddForceAtPosition(force, contact.point, ForceMode2D.Impulse);
}
}
This kinda works, but I feel like I’m doing something wrong because it doesn’t act the same as the equivalent bounciness on a normal physics material, it bounces less on flat ground, but sometimes goes chaotic when colliding with other dynamic things, especially with box shapes, who’s contact points can be in the far corners of the shape.
I would like to know if I’m doing something wrong in this code, or if there’s any other solution entirely.
Thanks!