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
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-01-2021 , 11:20   Re: Get direction player is moving relative to other player
Reply With Quote #2

This should be easily doable with a simple dot product between vectors a and b, where vector a is a unit vector in the direction from attacker's origin to victim's origin and b is a unit vector in the direction of attacker's velocity. You can think of a dot product as a projection of one vector onto the another one, like in this pic from Wikipedia's page on dot product:
.

If the a and b are parallel (that is, the attacker is moving towards the victim) then the dot product would be 1, and -1 if moving away (a and b are negatives of each other). Everything in between is, well, in between. To get a gradient between 0.5 and 1.5 it should be as simple as 1 + 0.5 * dot_product.
__________________

Last edited by klippy; 03-01-2021 at 11:22.
klippy is offline
 


Thread Tools
Display Modes

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