View Single Post
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