- Home /
Making an object bounce off a wall the same way light bounces off of a mirror.
Hello,
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?
Thanks!
So, when you use the game engine's built in bounce physics, it doesn't work? (If you set elasticity to 1.0 and friction to zero?)
What I did was make a new physics material with dynamic friction and static friction to zero and friction combine at $$anonymous$$imum and bounce combine at maximum. All the credit goes to the post linked below
Answer by kk93 · Feb 03, 2014 at 09:18 PM
I got an answer from unity forum.
http://forum.unity3d.com/threads/21138-Projectile-Bounce-Problem
Answer by gregroberts · Apr 22, 2015 at 01:37 PM
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.
Answer by GameDesignerBen · Jan 07, 2016 at 06:59 PM
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.
I had the same issue in 3D with balls sliding along walls ins$$anonymous$$d of bouncing. The equivalent setting seems to be:
Edit > Project settings > Physics > Bounce Threshold.
how did you sort this issue im having the same issue
This helped me! Been searching for quite a while and was already losing my sanity. Thanks for this! :)
Thank you! Lower the Velocity Threshold and everything worked like a charm.
Answer by oguzkagan · May 17, 2020 at 12:13 PM
i found the solution in this video: https://youtu.be/RoZG5RARGF0