Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

The problem of cue ball rotation in billiards

Discussion in 'Physics' started by shaoli198, Sep 6, 2019.

  1. shaoli198

    shaoli198

    Joined:
    Jun 23, 2019
    Posts:
    1
    Description: I have a game of billiards and I want to simulate the effect of billiard ball spinning. That is, the club hitting the ball at different points will produce different rotation effect. For example, if you hit the cue ball below the center of the ball, the ball will go forward and spin.

    My solution: a UI to adjust the offset, using the position of the cue ball plus the offset to hit the dot. Use AddForceAtPosition on the cue ball.

    Code (CSharp):
    1. offset = new Vector3(PlayerPrefs.GetFloat("offsetX"), PlayerPrefs.GetFloat("offsetY"), 0);
    2.  
    3. ball.AddForceAtPosition(direction.normalized *5, ball.position + offset,ForceMode.Impulse);
    4.  

    Problem: the offset is the obtained Vector2 set on the UI. Now, if it is moved along the Z axis, it is ok to offset x and y. How do you calculate the offset in the other direction? Known are the moving vector of the ball and the offset of Vector2 and the Angle of the club rotation
     

    Attached Files:

    • 1.png
      1.png
      File size:
      136.8 KB
      Views:
      97
  2. EliJNemer

    EliJNemer

    Joined:
    Aug 3, 2019
    Posts:
    38
    I was thinking about this I think that it might be a good idea to just have the UI as a ratiotic reference and you set the spin on the balls.. for example you hit the ball dead centre you do
    Code (CSharp):
    1. RB.AddForce(X,Y,Z,Force.Impulse);
    But if you didnt have friction on the table the ball would move forward with that force but not rotate. I would think you do so it does rotate. Now you can also add rotational velocity. So if you hit the ball at the bottom it adds rotational velocity as well with the add force.

    Does this make sense?