Answers for "Unity3d find angle/direction of a Ray / Raycasthit"
http://answers.unity.com/questions/1232662/unity3d-find-angledirection-of-a-ray-raycasthit.html
The latest answers for the question "Unity3d find angle/direction of a Ray / Raycasthit"Answer by Bunny83
http://answers.unity.com/answers/1233129/view.html
Well, the rules are pretty simple. The ball you hit moves along the hit normal and the ball that hits moves along the tangent of the hit point.
[Wikipedia ellastic collision][1] has this animated gif which should explain everything:
<a href="https://de.wikipedia.org/wiki/Datei:Elastischer_sto%C3%9F_2D.gif"><img src="https://upload.wikimedia.org/wikipedia/commons/2/2c/Elastischer_sto%C3%9F_2D.gif"></a>
So what you have to do is:
- get the normal vector of your collision
- calculate the tangent (in 2d simply rotate the normal 90°)
- Project the original velocity vector onto both normalized directions (normal, tangent)
- Apply the resulting vector as new velocity vectors for each ball.
This of course assumes that the two balls have the same mass.
This is how you calculate it manually. Keep in mind that the physics system might give you a different result due to some inaccuracies and rotations involved in the collision. Also keep in mind when you calculate it manually that it's possible to get a chain reaction of new collisions when more than 2 balls are involved. This might be difficult to simulate with a limited frame rate / certain step size.
For example a "split" of two balls with a third will result the wrong direction of the cueball if you process one collision at a time.
[1]: https://en.wikipedia.org/wiki/Elastic_collision#Two-dimensionalMon, 22 Aug 2016 17:09:29 GMTBunny83