|
Veteran Member
Join Date: Sep 2011
Location: Underworld
|
09-24-2015
, 17:22
Re: OnPlayerRunCmd calculate velocity to walk towards a point
|
#11
|
Quote:
Originally Posted by Miu
seems like this works
PHP Code:
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float move[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2])
{
float pos[3];
GetClientAbsOrigin(client, pos);
static float dest[3]; // place u want to go
float newmove[3];
pos[2] = 0.0;
dest[2] = 0.0;
SubtractVectors(dest, pos, newmove);
NormalizeVector(newmove, newmove);
ScaleVector(newmove, 450.0);
newmove[1] = -newmove[1];
float sin = Sine(angles[1] * FLOAT_PI / 180.0);
float cos = Cosine(angles[1] * FLOAT_PI / 180.0);
move[0] = cos * newmove[0] - sin * newmove[1];
move[1] = sin * newmove[0] + cos * newmove[1];
return Plugin_Changed;
}
|
Got DegToRad to avoid having to define pi and multiplying by pi /180
__________________
|
|
|
|