SetPlayerVelocity
#1

Hi, the question is how should I use this function to charge player towards his facing direction?
I've tried it myself, but it requires some advanced math and stuff, so I couldnt make it.

Really looking forward!
+ Rep if you'll help me.
Reply
#2

pawn Код:
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance) //An important function
{
    new Float:a;
    GetPlayerPos(playerid, x, y, a);
    GetPlayerFacingAngle(playerid, a);
    if (GetPlayerVehicleID(playerid))
    {
        GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }
    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}

#define VELOCITY 3.2 //The velocity you want to add

new Float:p_Vel[3];
GetVehicleVelocity(GetPlayerVehicleID(playerid),p_Vel[0],p_Vel[1],p_Vel[2]);
GetXYInfrontOfPlayer(playerid,p_Vel[0],p_Vel[1],VELOCITY);
SetVehicleVelocity(GetPlayerVehicleID(playerid,p_Vel[0],p_Vel[1],p_Vel[2]);
No idea if it'll work...
Reply
#3

Fixed the problem. Thanks for help, but that didnt helped. All I needed was to do this:
pawn Код:
X = X2 - X;
Y = Y2 - Y;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)