Facing a waypoint menu

User Tag List

Results 1 to 3 of 3
  1. #1
    stonebent's Avatar Member
    Reputation
    9
    Join Date
    Sep 2008
    Posts
    36
    Thanks G/R
    3/8
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Facing a waypoint

    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#

    Code:
            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?
    Last edited by stonebent; 10-12-2019 at 08:46 PM.

    Facing a waypoint
  2. #2
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1511
    Join Date
    May 2008
    Posts
    2,432
    Thanks G/R
    81/333
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Works for me.

    Code:
    var delta = target.Position - player.Position;
    var angle = Math.Atan2(delta.Y, delta.X);
    angle += Math.PI * 2;
    angle %= Math.PI * 2;

  3. #3
    stonebent's Avatar Member
    Reputation
    9
    Join Date
    Sep 2008
    Posts
    36
    Thanks G/R
    3/8
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It really does not want to work for me. I for example get 3.45678 when it should return 5.16789. The results are always inconsistent.

    -Edit-

    With this placement of coordinates, it works.
    I'll leave the solution here:

    Code:
    var target_x = Navigation.loadedXcoord;
    var player_x = Navigation.myCoordinates.x;
    var target_y = Navigation.loadedYcoord;
    var player_y = Navigation.myCoordinates.y;
    
    var atan2X = (player_x - target_x);
    var atan2Y = (player_y - target_y);
    
    double angle = (float)Math.Atan2(atan2X, atan2Y);
    
    angle += Math.PI * 2;
    angle %= Math.PI * 2;
    
    return (float)angle;
    Thank you Jadd, for pushing me in the right direction.
    Last edited by stonebent; 10-13-2019 at 05:01 PM.

Similar Threads

  1. [C#] Face and Walk thru your Waypoint code help?
    By noobnator in forum Programming
    Replies: 3
    Last Post: 05-22-2010, 05:11 PM
  2. Face bugs
    By CUratz in forum World of Warcraft Model Editing
    Replies: 9
    Last Post: 11-02-2006, 04:58 PM
  3. Face in Chair
    By Neocloud in forum World of Warcraft Exploits
    Replies: 1
    Last Post: 09-09-2006, 10:07 PM
  4. Face in Chair
    By Neocloud in forum World of Warcraft Exploits
    Replies: 2
    Last Post: 09-09-2006, 08:48 PM
  5. Pwn their face.. with pets!
    By janzi9 in forum World of Warcraft Exploits
    Replies: 5
    Last Post: 04-15-2006, 01:00 AM
All times are GMT -5. The time now is 04:24 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search