Calc Facing menu

User Tag List

Thread: Calc Facing

Results 1 to 6 of 6
  1. #1
    kingdeking's Avatar Member
    Reputation
    4
    Join Date
    Oct 2008
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Calc Facing

    Hey,

    I have problems calculating how my player needs to rotate in order to face a mob.

    What I do now is this:

    Code:
    facing = (Pos.x * Object.x + Pos.y * Object.y + Pos.z * Object.z ) / ( sqrt(  pow(Pos.x, 2) + pow(Pos.y, 2) + pow(Pos.z, 2) ) * sqrt(  pow(Object.x, 2) + pow(Object.y, 2) + pow(Object.z, 2) ) );
    
    temp = acos(facing);
    This basically gives me the angle between two vectors. The two vectors are the player and the mob. But the value temp is not 0, nor 2Pi, when I face a mob.

    Calc Facing
  2. #2
    miceiken's Avatar Contributor Authenticator enabled
    Reputation
    209
    Join Date
    Dec 2007
    Posts
    401
    Thanks G/R
    7/9
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dude. you make a new thread for everything, and everything I see from you has already been answered atleast 5 times before. For god's sake please search before making a new thread.

  3. #3
    kingdeking's Avatar Member
    Reputation
    4
    Join Date
    Oct 2008
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont understand sry

  4. #4
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well... clear your linear algebra up. What you are utilizing is the dot product between two vectors. By incidence, it defined as
    Code:
    a . b = |a| * |b| * cos(<the angle between a and b>)  
    <=> (a . b) / (|a| * |b|) = cos(<the angle between a and b>)
    <=> arccos((a . b) / (|a| * |b|)) = <the angle between a and b>
    So you are missing arccos for the angle to be between 0 and 2 Pi. Actually.

    But what you are trying to compute is not the facing, but the angle between your position and the object's position relative to the origin [1] (and even considering the z coordinate, which will give you inappropriate results if you think about it).
    You would need to compute the angle between the direction you are facing and the offset of the object's position relative to your own.
    i.e.:
    Code:
    float ownFacing = LocalPlayer.GetFacing(); // the angle like that saved somewhere in the movement struct 
    C2Vector direction(-sin(ownFacing), cos(ownFacing)); // facing of 0 is facing north iirc
    C2Vector objectOffset = static_cast<C2Vector>(object.GetPosition() - LocalPlayer.GetPosition());
    float dot = direction.Dot(objectOffset);
    float denominator = direction.GetLength() * objectOffset.GetLength();
    return arccos(dot/denominator);
    Other examples in this forum are using Atan of the triangle described by objectOffset and substracting the own facing value. But this should be the "normal" vector computational way for computing facing delta.

    Edit: note that there might be an error in the way I compute the angle (WoW's 'special' coordinate system, the facing north assumption, etc.), but It should generally provide the right results.
    Last edited by Bananenbrot; 08-11-2012 at 06:41 AM. Reason: xample

  5. #5
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1515
    Join Date
    May 2008
    Posts
    2,433
    Thanks G/R
    81/336
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

  6. #6
    kingdeking's Avatar Member
    Reputation
    4
    Join Date
    Oct 2008
    Posts
    50
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, i got everything working now. Killing mobs like a boss now! Props to all you guys helpin me. My bot is gathering and killing mobswhen necessary now, so amazing ^^

Similar Threads

  1. UD female face with man hair
    By beebo in forum WoW ME Questions and Requests
    Replies: 6
    Last Post: 11-08-2006, 06:18 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 02:38 PM. 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