# Calculating rigid ball deflection angles and velocities

I am trying to get 2 rigid 2d circles with different masses to bounce off each other. Does anybody have a formula or a C# method for these calculations?

I found this formula for calculating ball to ball deflections, but I realized that it doesn't compute deflection angles.

```
float vx1 = (rigidbody2D.velocity.x * (m1 - m2) + (2 * m2 * otherRigidbody2D.velocity.x)) / (m1 + m2);
float vy1 = (rigidbody2D.velocity.y * (m1 - m2) + (2 * m2 * otherRigidbody2D.velocity.y)) / (m1 + m2);
float vx2 = (otherRigidbody2D.velocity.x * (m2 - m1) + (2 * m1 * rigidbody2D.velocity.x)) / (m1 + m2);
float vy2 = (otherRigidbody2D.velocity.y * (m2 - m1) + (2 * m1 * rigidbody2D.velocity.y)) / (m1 + m2);
rigidbody2D.velocity = new Vector2(vx1, vy1);
otherRigidbody2D.velocity = new Vector2(vx2, vy2);
```

Comment

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.