Sign in to follow this  
Viks

moving a golf ball on the XZ-plane

Recommended Posts

Viks    100
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.

Share this post


Link to post
Share on other sites
zaneski13    104
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]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this