Jump to content
  • Advertisement
Sign in to follow this  
Viks

moving a golf ball on the XZ-plane

This topic is 3046 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!