I have a cylindrical object with a capsule collider with all rotations fixed and y position fixed. I want to make it so that when this object hits a wall, it bounces off at a same degree as a light bouncing off of a mirror. Just like this:
which is how Vector3.Reflect works. Unfortunately, I have learned that using the built-in physics engine, this result is not easy to achieve. Is there a known method of tweaking the parameters of physics setting to achieve this?
Just so its self contained, here is the forum answer from GargarethSunman:
If you want perfect bounces, you’ll need to:
- set drag and angular drag to 0 on the projectile’s rigidbody,
- create a physic material with all friction settings set to 0, bounciness set to 1, friction combine set to minimum, and bounce combine set to maximum, and
- put that physic material on the projectile.
I was still running into problems with this in 2D, where an object would collide with a wall and then kind of slide along it instead of bouncing off again.
I had to go into Edit → Project Settings → Physics2D and lower the Velocity Threshold, as any collision lower than that velocity is considered inelastic. Bumped it down a bit and suddenly everything worked like a charm.