27.04.2017, 21:29
You'll have to tetrieve the Angle of the Vehicle and based on that, a Vector pointing to the same direction.
To make the boost effective at all times you also have to calculate the current total velocity (X/Y) and make the new vector length longer than the current (else you will not speed up).
Make sure to also limit vx, vy, vz by an absolute value, you'll be able to boost yourself out of existance very easily otherwise.
vz remains untouched but you can also multiply it by VELOCITY_BOOST if you want to.
You can also leave away the vl calculation but that will make the speed boost always have the same strength. I personally prefer stronger boosts at higher speeds.
To make the boost effective at all times you also have to calculate the current total velocity (X/Y) and make the new vector length longer than the current (else you will not speed up).
Код:
#define VELOCITY_BOOST 1.6 new Float:vx, Float:vy, Float:vz, Float:a, Float:vl; GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz); // Get current Velocity vl = floatsqroot(vx*vx + vy*vy); // Calculate X/Y Vector length to be able to calculate a Vector which is definitely higher than this GetVehicleZAngle(GetPlayerVehicleID(playerid), a); // Get Angle vx = vl * VELOCITY_BOOST * floatsin(-a, degrees); // This calculates a new Vector, pointing in the direction of a and multiplied by VELOCITY_BOOST vy = vl * VELOCITY_BOOST * floatcos(-a, degrees); SetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
vz remains untouched but you can also multiply it by VELOCITY_BOOST if you want to.
You can also leave away the vl calculation but that will make the speed boost always have the same strength. I personally prefer stronger boosts at higher speeds.