- Home /
Math Q: Compensating for ball radius on a reflection.
Hey guys,
Below is a photo of the current problem I am working on for a mini golf game. To get the shot vector for the computer I reflect the goal position over the wall and shoot at this position. This works great!
Problem: It seems the bigger the ball the less accurate my shots get. I think I need to adjust the Reflection point of the goal to compensate for the radius of the ball. I'm not sure exactly how to do this.
Thanks for your time in advance.
Answer by Fattie · May 05, 2013 at 08:44 PM
I'm not precisely sure what you want, but here's the usual smarty-pants solution:
make a fake wall, one radius away. then the calculation is very easy.
amazing huh ?? je keffe
You've stated the problem here perfectly. The solution is just not what I am looking for. I am looking for a way to adjust the shot vector to account for the radius. currently that shot vector is (reflectedGoalPosition - golfBallPosition).normalized I really appreciate it!
At the moment in your calculation you are "bouncing" it off the black wall. Am I correct?
Do not bounce it off that black wall. Ins$$anonymous$$d, bounce it off the imaginary blue line I have drawn, which is one radius away from that black wall. (radius, I mean radius f the green ball.)
O$$anonymous$$ ?
I have the collisions happening on the outside of the ball so ins$$anonymous$$d of bouncing off the imaginary blue line, shouldn't I be reflecting the hole over the blue line? is this what you mean?
Oh wow sorry that took me longer then it should have I got it now Thank you!
$$anonymous$$agnificent! Isn't it a clever solution ?
For future readers, you "bounce" the center of the green ball, off the imaginary line.
Rock on ...
Answer by Chronos-L · May 06, 2013 at 04:08 AM
A user and I (the user whose name I do not remember provide the start-up algorithm, I tested and completed it) have answered a question on calculating the ghost-ball and the reflected guideline for a billiard game.
You can check it out and see if it helps : http://answers.unity3d.com/questions/430552/i-want-to-make-billiards-game-help-me.html