vehicle boost
#6

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).

Код:
#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);
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.
Reply


Messages In This Thread
vehicle boost - by sams90 - 26.04.2017, 12:25
Re: vehicle boost - by sams90 - 27.04.2017, 12:10
Re: vehicle boost - by Hansrutger - 27.04.2017, 12:30
Re: vehicle boost - by iGetty - 27.04.2017, 14:03
Re: vehicle boost - by sams90 - 27.04.2017, 14:09
Re: vehicle boost - by NaS - 27.04.2017, 21:29
Re: vehicle boost - by ShaharG - 27.04.2017, 21:54
Re: vehicle boost - by sams90 - 28.04.2017, 04:16
Re: vehicle boost - by sams90 - 29.04.2017, 03:54
Re: vehicle boost - by Sew_Sumi - 29.04.2017, 05:44

Forum Jump:


Users browsing this thread: 1 Guest(s)