I'm using Unity C#. How would I create the effect in my pool game, a line showing the direction of the second (not white) ball after collision. Example: enter image description here

I need to make the line coming from the ball (second/leftmost)

P.S. I made the other line by using Raycast to find the hit point and set that point last position of line renderer (white ball is a start position for line renderer and it casts the ray)

  • \$\begingroup\$ Is that path on the right already done and calculated? With the ball being the correct size and everything? \$\endgroup\$ Commented Jan 30, 2017 at 16:21
  • \$\begingroup\$ I am using a raycast to find the second position for the line renderer so I have managed to create the line from the white ball to the target ball. I only have the line, not the ball (imaginary circle). I'm trying to make the imaginary circle that would fit well \$\endgroup\$
    – John Smith
    Commented Jan 30, 2017 at 16:51
  • \$\begingroup\$ You could get the bounds of the real ball and then make the imaginary circle with that bound extent. That should clear that part up. I'll try drafting an answer for the second line (on the left) if I can. \$\endgroup\$ Commented Jan 30, 2017 at 17:20
  • \$\begingroup\$ What if there is two or more balls which would mean the ball should be visualized to be in contact and fitted yet without overlapping any of them \$\endgroup\$
    – John Smith
    Commented Jan 30, 2017 at 17:24
  • 1
    \$\begingroup\$ That's the point: don't raycast at all. Replace your raycast with a SphereCast. That way it stops and reports a hit as soon as it runs out of space for the full ball to fit, rather than a ray giving you a "false collision" in a crevice too narrow for the ball to actually enter without colliding with something else first. \$\endgroup\$
    – DMGregory
    Commented Jan 30, 2017 at 22:13

2 Answers 2


The direction (d) in which the target ball should move is AB.normalized, where A is the center of the imaginary circle (where cue ball reaches next to target ball) and B is the center of target ball.

Obviously d will not be equal to AB.normalized if shot has an angle. i.e. if shot is done in a way that cue ball receives a clockwise rotation, then the target ball will receive a counter-clockwise rotation less than the rotation of cue ball as well as an additional force resulting from the torque of the cue ball.

The amount of rotation reduction and the additional force depend on physical attributes of the elements of the game. e.g. ball friction, pool friction, bounciness, etc..

If your game mechanics depend on Unity's Physics Engine then you probably will have a hard time estimating the exact value for these vectors. However if you go on writing your own physics engine (which is better in the end) you have to first write all your physics equations and integrate them into the visual representations shown in the picture to have the same visual and physical behavior.


I'm not a physics scientist so I don't know the equations you need. But you will certainly find them here.

  • \$\begingroup\$ Thanks for answering. How would I calculate the imaginary ball in case say there are two balls near, how would I make sure that the imaginary ball does not overlap the others? \$\endgroup\$
    – John Smith
    Commented Jan 29, 2017 at 16:32
  • \$\begingroup\$ That would be another problem to solve but first thing that comes to mind is using raycast which might be the best option anyway \$\endgroup\$
    – Bizhan
    Commented Jan 29, 2017 at 16:56

What you're looking for is Elastic Collision because you have billiard balls and this will be the closest approximation. To make it absolutely realistic you'll need a mix of Inelastic Collision and Elastic Collision but that's another topic altogether.

The balls in this case will act like a Two-dimensional Gas and you can find the math here. I'm not going to detail how to do this, simply because it's a lot of groundwork. If you're unsure about the implementation (of the math and physics not the game engine part) I'd suggest asking on the Physics site of StackExchange.

  • 1
    \$\begingroup\$ This provides insight,but it directs the user to another page in order to answer the question being asked. As such, it is a "link-only" answer. \$\endgroup\$
    – Gnemlock
    Commented May 14, 2017 at 23:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .