Archived

This topic is now archived and is closed to further replies.

Shooting / maths q

This topic is 5127 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. Ok, Im trying to let the player fire a projectile. When you click the "fire" key, I do this: xMove = (float)sin(heading*piover180) * MoveDistance; zMove = (float)cos(heading*piover180) * MoveDistance; yMove = (float)sin(lookupdown*piover180) * MoveDistance; The names might look familiar to tutorial readers These figures are then added to the projectile position each frame, which works fine. The problem is that the higher or lower you shoot, the more off the aim is, and its impossible to shoot stright up or down. My maths isnt great I know, but what am I doing wrong? Thanks... zoidy

Share this post


Link to post
Share on other sites
Your "y" goes up and down without affecting the "x" and "z".

Just put a breakpoint right at where xMove is assigned, and look at what values come out for xMove, yMove, and zMove, and you''ll see what it is.

And, for the reader who don''t have your code: you need to scale xMove and zMove by cos(lookupdown*piover180).

Share this post


Link to post
Share on other sites