# Unity RigidBody not rebounding as expected on low-impact collisions

I have a Rigidbody2D with a CircleCollider2D, on which I display a sprite of a circle. This Rigidbody can be "shot" in my game.

I also have 4 rectangular BoxCollider2Ds on the edges of the game screen.

When I shoot the circle, it rebounds fine from the rectangular colliders, except for cases when the impact velocity normal to the rectangular collider's surface is very small. In that case, the rebound velocity in that direction is somehow zero.

Here is the circle's RigidBody2D and CircleCollider2D setup:

Here is the BoxCollider2D of the rectangular collider:

The material "New Physics Material 2D" attached to the ball and the BoxColliders has Friction set to 0 and bounciness set to 1:

Here are two gifs, the first one demonstrating how it works (correctly) in most cases, and the second one demonstrating what happens on a low velocity impact. The "choppiness" of these gifs is due their "giffy" nature. In my game, the movement is smooth.

I'm wondering why, on the low-velocity impacts, the ball doesn't rebound in the same way as on the high-velocity impacts (i.e, by the outbound angle = inbound angle rule)?

----------------------------

Edit:

----------------------------

I stepped into the circle's void OnCollisionEnter2D(Collision2D collision) method, and, sure enough, on the very slow collisions, the collision.otherRigidbody.velocity had a zero-component for the slow velocity of the incoming collision (so depending on whether the impact's x- or y-velocity was slow, the respective component of the resulting velocity was, for whatever reason, set to 0).

Oddly enough (at least for me - I am still not completely familiar with all of Unity's in's and out's), the collision.relativeVelocity had been updated to hold the correct resulting velocity of the impact. Thus, by adding following code to the OnCollisionEnter2D method, I am able to handle the collision correctly, even on low-impact collisions:

if (collision.otherRigidbody.velocity.x == 0)
{
collision.otherRigidbody.velocity = new Vector2(collision.relativeVelocity.x, collision.otherRigidbody.velocity.y);
}
if (collision.otherRigidbody.velocity.y == 0)
{
collision.otherRigidbody.velocity = new Vector2(collision.otherRigidbody.velocity.x, collision.relativeVelocity.y);
}


While this seems to solve the issue I am experiencing, it doesn't seem to me that I should need to be doing this...

• You say the bouncy physics material is used on your ball and box colliders, but in your gif the box colliders show no physics material applied. Was this captured from an older version, or is it possible the material didn't get applied as expected? Jan 20, 2020 at 17:11
• Hey DMGregory, thanks for your comment. You are right, that was captured from an old version. I have updated the post with a new gif. Jan 20, 2020 at 19:50
• Could some of the energy of the collision be going into adding spin to the ball, or something like that? Jan 20, 2020 at 20:13
• I am not sure... I did try setting the angular drag on the circle's RigidBody2D to 0.00 (it was set to 0.05 by default, as can be seen in the first screenshot above), but that did not change the behaviour.. I also played around with the Collision detection mode (Discrete versus Continuous) and the Interpolation Mode (None, Interpolate, Extrapolate) of the circle's RigidBody2D, but that didn't change the behaviour either :/ Jan 20, 2020 at 23:25
• I have added an edit at the end of the original post, as I seem to have found a way around this issue. But it doesn't seem to me that I should need to be doing what I am describing in that edit... Jan 21, 2020 at 0:12