moving a golf ball on the XZ-plane
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.
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]
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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement