[SOLVED!] I’m encountering an issue in my Unity 2D game where a ball with a Bounce of 1 and Friction of 0 gets stuck to the wall when hitting it at a low angle, instead of bouncing off as expected.
I’ve experimented with various directions of impact and noticed that when the ball’s velocity vector is below (0.26, 1), it sticks to the wall. However, with a velocity vector above (0.26, 1), it bounces off correctly.
I’ve tried adjusting the Bounce Threshold in the Project Settings → Physics to lower values but to no avail.
Has anyone experienced a similar issue or have suggestions on how to prevent this sticking behavior?
Here are the images illustrating the issue:
- Before starting game, the ball is near the wall.
-
At velocity (0.25, 1):
the ball stuck to the wall
-
At velocity (0.26, 1):
the ball would bounce off as expected.
Thank you in advance!
Solution Update:
After several hours of troubleshooting, I’ve discovered a fix for the issue where a ball with a Bounce of 1 and Friction of 0 gets stuck to a wall upon collision at low angles in Unity 2D.
For those working in 3D, setting the Bounce Threshold to 0 in the Project Settings → Physics might resolve similar issues. However, in the 2D environment, the key is to adjust the Velocity Threshold within the Physics2D settings.
Here’s the step-by-step solution:
- Navigate to
Edit -> Project Settings -> Physics2D
. - Look for the
Velocity Threshold
option. - Lower the Velocity Threshold value. This is crucial because Unity considers any collision with a velocity below this threshold to be inelastic, which was causing the ball to stick rather than bounce.
By adjusting this setting, collisions at low velocities are now treated as elastic, allowing the ball to bounce off the wall as intended, regardless of the angle of impact.
I hope this solution saves time for anyone facing a similar problem!