moving a golf ball on the XZ-plane

Started by
1 comment, last by Viks 14 years, 2 months ago
Hi, I am working on a golf game and want to implement ball movement in all directions (on the XZ-plane). I am using keyboard up and down arrow keys for shot direction selection, but I am not able to get the angles right. I am hoping to get some information on this. Please do let me know if anyone has any ideas.
Advertisement
If I understand you correctly...

You could use an unit circle where...

pos.x = ( radius * cos((rot.y-90 ) * (PI/180)) ) + pos.x;
pos.z = ( radius * sin((rot.y+90 ) * (PI/180)) ) + pos.z;

This is code from my camera class so rot.y is just the angle / yaw I had to add 90 to make it work. In your app you'll have to experiment with different numbers to add to the angle. 0, 90, 180, or 270.


Also Note: the radius is the distance the ball would move every frame

[Edited by - zaneski13 on February 17, 2010 6:28:31 PM]
Thanks! That was really helpful. I did adjust the angles and finally got it to work!

This topic is closed to new replies.

Advertisement