PDA

Просмотр полной версии : [Function] GetVehicleDriftAngle



Salvacore
08.08.2014, 18:18
GetVehicleDriftAngle(vehicleid, &Float:fVehDriftAngle)
{
static
Float: fVehVelocity[3],
Float: fVehAngle,
Float: fVehMoveAngle
;

if (!GetVehicleVelocity(vehicleid, fVehVelocity[0], fVehVelocity[1], fVehVelocity[2]))
return 0;

if (!floatcmp(fVehVelocity[0], 0.0) && !floatcmp(fVehVelocity[1], 0.0))
{
fVehDriftAngle = 0.0;
return 1;
}

fVehMoveAngle = -atan2(fVehVelocity[0], fVehVelocity[1]);

GetVehicleZAngle(vehicleid, fVehAngle);

if (floatcmp(fVehAngle, 180.0) == 1)
fVehAngle -= 360.0;

fVehDriftAngle = floatsub(fVehMoveAngle, fVehAngle);

if (floatcmp(fVehDriftAngle, -180.0) == -1)
fVehDriftAngle += 360.0;

else if (floatcmp(fVehDriftAngle, 180.0) == 1)
fVehDriftAngle -= 360.0;

return 1;
}

Направление заноса

Угол < 0 - смещение носа влево относительно направления движения.
Угол > 0 - смещение носа вправо относительно направления движения.


Автор: Strix