playMaker

Author Topic: Snooker / billiards / pool ball direction  (Read 1263 times)

LogLady

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Snooker / billiards / pool ball direction
« on: April 17, 2015, 02:22:50 PM »
Hello!

I'm trying to trace the direction that a ball will do before I shoot it just like you see on snooker games. This is a exact example of what I want to accomplish: https://youtu.be/y-ybJf7GLaA?t=1m25s

Any help is appreciated.

Thanks!

inyourbus

  • Playmaker Newbie
  • *
  • Posts: 43
  • In Your Legends
    • View Profile
    • In Your Legends
Re: Snooker / billiards / pool ball direction
« Reply #1 on: April 19, 2015, 05:18:30 AM »
Could you do a raycast, then when the ray hits the wall or ball raycast again with reflection from the hit position and so on...

Then draw a line using line renderer.

Thats my best guess.
One step at a time..

LogLady

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: Snooker / billiards / pool ball direction
« Reply #2 on: April 23, 2015, 06:48:05 AM »
Using the draw line action I got it working right for the first ray but I couldn't cast the second ray to the right direction. I positioned an object at the point the first ray hit but the ray is not pointing to the direction that the ball do when shot. Maybe I'm doing wrong using the Vector3 operator Reflect where I use the origin of the first ray as the first vector3 and the hit point of the ray as the second vector3. The result gives values higher than the game area.

Any help is appreciated!

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Snooker / billiards / pool ball direction
« Reply #3 on: April 23, 2015, 07:01:31 AM »
This is a tricky thing to do, I think. I don't really have a solution since it would require a decent bit of tinkering with trial and error but the first thing I did think about was the need for a Spherecast rather than a Raycast.

Raycasts have no width but the balls are going to collide at the tanget point rather than the center, where the raycast is going... So it will make all of the reflected vectors incorrect in terms of the actual physics results. Plus, all of the other factors like friction, rotational torque, cushion flexibility etc are all not going to be accounted for so the reflections might be close, but not accurate.

LogLady

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: Snooker / billiards / pool ball direction
« Reply #4 on: April 23, 2015, 08:56:00 AM »
As close as a snooker game like Side Pocket would be great  :D .
I'm not making a snooker it is just for debug purposes, not actual gameplay.

Sadly the Spherecast actions on the Ecosystem give less resources than the Raycast function as to store the hit position and the object hit by the ray but it is the first time I'm using the spherecast so maybe I'm doing something wrong or expecting.

Lane, could you please clarify it a bit more?
« Last Edit: April 23, 2015, 01:31:55 PM by LogLady »

LogLady

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: Snooker / billiards / pool ball direction
« Reply #5 on: June 08, 2015, 11:23:22 AM »
Thanks for your great help, inyourbus !  :)