AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Calculating velocity from angles (https://forums.alliedmods.net/showthread.php?t=294539)

Blinx 03-01-2017 12:34

Calculating velocity from angles
 
How do I calculate an entity's velocity if I want to push it in a direction with given angles? FF2 partially has the answer but not for the Z velocity:
PHP Code:

velocity[0]+=Cosine(DegToRad(angles[0]))*Cosine(DegToRad(angles[1]))*500*multiplier;
velocity[1]+=Cosine(DegToRad(angles[0]))*Sine(DegToRad(angles[1]))*500*multiplier;
velocity[2]=(750.0+175.0*charge/70+2000)*multiplier


Weetabix 03-01-2017 13:59

Re: Calculating velocity from angles
 
Maybe:

PHP Code:

stock void AnglesToVelocity(float vAngles[3], float fScalefloat vOut[3])
{
    
float vDirection[3];
    
GetAngleVectors(vAnglesvDirectionNULL_VECTORNULL_VECTOR);
    
    
ScaleVector(vDirectionfScale);
    
    
fOut vDirection;



Chdata 03-02-2017 11:36

Re: Calculating velocity from angles
 
I have this, which I happen to use for some things.

PHP Code:

stock AnglesToVelocity(Float:fAngle[3], Float:fVelocity[3], Float:fSpeed 1.0)
{
    
fVelocity[0] = Cosine(DegToRad(fAngle[1]));
    
fVelocity[1] = Sine(DegToRad(fAngle[1]));
    
fVelocity[2] = Sine(DegToRad(fAngle[0])) * -1.0;
    
    
NormalizeVector(fVelocityfVelocity);
    
    
ScaleVector(fVelocityfSpeed);


I dunno the difference.

Blinx 03-03-2017 15:49

Re: Calculating velocity from angles
 
Weetabix' solution is correct and works dandy, ty for that.


All times are GMT -4. The time now is 21:08.

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