Raised This Month: $ Target: $400
 0% 

Solved Get direction player is moving relative to other player


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Effeff
AlliedModders Donor
Join Date: Jan 2019
Location: discord: ff#0533
Old 03-02-2021 , 14:45   Re: Get direction player is moving relative to other player
Reply With Quote #5

Awesome, changed it to the snippet below and it works perfectly.
Thank you so much for your explanation!

I feel a bit silly for what I did with the AddVectors part - I started with a velocity vector, used it to get the next position, and then used the two positions to just get the same velocity vector back

PHP Code:
float GetDamageVelocityModifier(int attackerint victim)
{
    
float attackerPos[3], victimPos[3], unitVec[3], attackerVel[3];
    
GetClientAbsOrigin(attackerattackerPos);
    
GetClientAbsOrigin(victimvictimPos);
    
MakeVectorFromPoints(attackerPosvictimPosunitVec);
    
GetEntPropVector(attackerProp_Data"m_vecVelocity"attackerVel);
    
NormalizeVector(unitVecunitVec);
    
NormalizeVector(attackerVelattackerVel);
    
float dp GetVectorDotProduct(unitVecattackerVel);
    
PrintToChatAll("dot product: %f"dp);
    return 
0.5 dp;

If anyone reading is curious, here's a video of what I'm doing:



(note that the damage in chat is wrong because armor appears to eat 50% of damage).
Effeff is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode