Raised This Month: $ Target: $400
 0% 

Air/Ground Speed Boost


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-07-2016 , 04:14   Re: Air/Ground Speed Boost
Reply With Quote #6

It's rather easy, just some simple vector math.

If you want to increase velocity magnitude (speed) by a relative amount (a percentage) in the current direction, you can just multiply it by a scalar value, i.e (you have to include xs.inc):
PHP Code:
new FloatfVelocity[3];

pev(idpev_velocityfVelocity);
xs_vec_mul_scalar(fVelocity1.5fVelocity); // 50% speed boost
set_pev(idpev_velocityfVelocity); 
If you want to increase velocity magnitude by an absolute amount, you have to get a unit vector in the current direction, multiply it by your desired amount, and add it to the current velocity:
PHP Code:
new FloatfVelocity[3], FloatfDirection[3];
    
pev(idpev_velocityfVelocity);
xs_vec_normalize(fVelocityfDirection); // Get unit vector that has the same direction as velocity
xs_vec_mul_scalar(fDirection100.0fDirection); // Multiply it by 100, giving us a vector with magnitude of 100
xs_vec_add(fVelocityfDirectionfVelocity); // Add these 2 together
set_pev(idpev_velocityfVelocity); 
klippy 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 09:27.


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