# 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);
```

### 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.

### Follow this Question

### Related Questions

How to make a ball bounce always to the same height? 2 Answers

Ball passes through the floor on movement 1 Answer

How do you put an image on the screen and keep it there? 0 Answers

Changing ball direction left/right by swipe on an auto generated path 0 Answers

the boy just can only move in the horizontal direction 1 Answer