# Rigidbody sticks to walls. Or, how the h*ll do you force elastic collisions?

There’s at least a dozen posts on this topic, none of which seem to answer anything conclusively. I have four cubes to which I’ve attached rigidbody2d and box collider 2d components. I have a single sphere, to which I’ve assigned a rigidbody2d and a circle collider.

If the sphere is moving too slowly when it approaches the wall, any motion perpendicular to the surface is removed and all that remains is motion parallel to the surface.

I really only want to simulate a circle bounding around in a square. Surely this is possible with Unity?

Additional info: Friction and drag are abolished on the all objects in the scene via physics2d materials. There is no drag.

It’s actually a configurable setting.

In the 2D physics setting, `Velocity Threshold` dictates the cutoff x where collisions with relative velocity lower than x will be treated as inelastic.

Ultimately, you can’t force Unity to treat all collisions as elastic, but by setting `Velocity Threshold` sufficiently low you can cause nearly all collisions to be treated elastically. If you don’t have complex colliders and relatively few colliding bodies, you won’t incur a substantial performance hit.

This is not as trivial as you think it is. You will need to create a function that calculates the new vector on collision. There are plenty of formulae for perfect elastic collisions on the internet (it’s classic physics). Using those you can determine a new vector based on your entry vector. Don’t think there is anything already implemented in Unity that does this innately, so you’ll have to implement it yourself. For a perfectly elastic collision, you will also have to set the mass of the squares to be far larger than the mass of the object you want to bounce off the squares.