Sandstrom

wow
Facing a waypoint

3 posts in this topic

Greetings,

I've been trying for days to figure out how to calculate where I need to turn in order to face my waypoint. I am aware that there's been several threads created asking for this - in which solutions has been posted. However, nothing is giving me equitable results.

So the question is: How do I calculate what my player rotation has to be (out of PI*2) in order to face my waypoint which is at: X:55.24, Y:66.89

I get my player rotation from the wow API - GetPlayerFacing(). The coordinates I'm working with are formatted as such:
55.71, 67,51

This is one of the functions I've tried (Which has returned utterly wrong angles) It's however returning something... But I found no pattern in the results:

C#

 
        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show(GetFacingAngle().ToString());
        }

        public static float GetFacingAngle()
        {
            float angle = (float)Math.Atan2(target_y - player_y, target_x - player_x);

            if (angle < 0.0f)
            {
                angle = angle + (float)Math.PI * 2.0f;
            }
            else if (angle > (float)Math.PI * 2)
            {
                angle = angle - (float)Math.PI * 2.0f;
            }
            return angle;
        }

What am I doing wrong?

2 people like this

Share this post


Link to post
Share on other sites

could it be because in order for Math functions to use your coordinates, you need to convert to radian?

see 

Please login or register to see this link.

 , im not good with this sorta shit so i cba trying shit all night to figure this one out :P

 

(also check 

Please login or register to see this link.

 as a reference)

3 people like this

Share this post


Link to post
Share on other sites
3 hours ago, Setavai said:

could it be because in order for Math functions to use your coordinates, you need to convert to radian?

see 

Please login or register to see this link.

 , im not good with this sorta shit so i cba trying shit all night to figure this one out :P

 

(also check 

Please login or register to see this link.

 as a reference)

Hey, thanks for the response. I actually solved the issue. I had done the math just a tiny bit wrong. Placed in the right order now, I get the desired results.

Cheers!

3 people like this

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.