[Classic] 1.13.2.32089 - Angle from player to point menu

User Tag List

Results 1 to 4 of 4
  1. #1
    NoxiaZ's Avatar Active Member
    Reputation
    23
    Join Date
    May 2019
    Posts
    101
    Thanks G/R
    21/12
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Classic] 1.13.2.32089 - Angle from player to point

    Hi,

    I struggle with the function to determine the angle from the player to a point/mob, to know if the point/mob is behind.

    I have these functions:

    Code:
    public float DotProduct(Vector3 unitPosition)
    {
        unitPosition.Z = PlayerPosition.Z;
        var rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, PlayerRotation);
        var forward = Vector3.Normalize(Vector3.Transform(new Vector3(0, 1, 0), rotation));
        var targetDirection = Vector3.Normalize(unitPosition - PlayerPosition);
        var dot = Vector3.Dot(targetDirection, forward);
        return dot;
    }
    
    public bool IsBehind(Vector3 unitPosition)
    {
        var angle = Angle(unitPosition);
        if (angle <= 180)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
    
    public float Angle(Vector3 unitPosition)
    {
        unitPosition.Z = PlayerPosition.Z;
        var rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, PlayerRotation);
        var forward = Vector3.Normalize(Vector3.Transform(PlayerPosition, rotation));
        var targetDirection = Vector3.Normalize(PlayerPosition - unitPosition);
        return forward.Angle(targetDirection);
    }
    The DotProduct, seems to be working well, but the Angle method return different values depending where i stand and look at the mob, any one have solved this, and can tell me what i'm doing wrong?

    [Classic] 1.13.2.32089 - Angle from player to point
  2. #2
    ChrisIsMe's Avatar Contributor
    Reputation
    164
    Join Date
    Apr 2017
    Posts
    210
    Thanks G/R
    67/100
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    isFacing(Self,Unit)

    return ((selfPosX-targetPosX)*math.cos(-Rotation))-((selfPosY-targetPosY)*math.sin(-Rotation)) < 0 or distance(self,target) < 1.5;

  3. Thanks NoxiaZ (1 members gave Thanks to ChrisIsMe for this useful post)
  4. #3
    NoxiaZ's Avatar Active Member
    Reputation
    23
    Join Date
    May 2019
    Posts
    101
    Thanks G/R
    21/12
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by ChrisIsMe View Post
    isFacing(Self,Unit)

    return ((selfPosX-targetPosX)*math.cos(-Rotation))-((selfPosY-targetPosY)*math.sin(-Rotation)) < 0 or distance(self,target) < 1.5;
    Thank you so much, this is working perfectly.
    May i ask which language you use?

  5. #4
    ChrisIsMe's Avatar Contributor
    Reputation
    164
    Join Date
    Apr 2017
    Posts
    210
    Thanks G/R
    67/100
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by NoxiaZ View Post
    Thank you so much, this is working perfectly.
    May i ask which language you use?
    C++, this is lua though.

Similar Threads

  1. [Classic] 1.13.2.32089 - WorldToScreen
    By NoxiaZ in forum WoW Memory Editing
    Replies: 5
    Last Post: 07-18-2021, 07:19 AM
  2. [Classic] 1.13.2.32089 - SpellBook, Cooldowns, WorldToScreen
    By NoxiaZ in forum WoW Memory Editing
    Replies: 8
    Last Post: 04-17-2020, 10:31 AM
  3. [Classic] 1.13.2.32089 - Spell Names?
    By NoxiaZ in forum WoW Memory Editing
    Replies: 11
    Last Post: 12-26-2019, 04:43 AM
  4. [Classic] 1.13.2.32089
    By SatyPardus in forum WoW Memory Editing
    Replies: 24
    Last Post: 11-05-2019, 08:49 PM
  5. [Classic] [Classic] 1.13.2.32089 - Learned Spells
    By NoxiaZ in forum WoW Memory Editing
    Replies: 14
    Last Post: 10-17-2019, 04:32 PM
All times are GMT -5. The time now is 11:18 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search