Skip to content

Instantly share code, notes, and snippets.

@StrixG
Created May 22, 2015 13:35
Show Gist options
  • Save StrixG/bdc299b939dbbd455795 to your computer and use it in GitHub Desktop.
Save StrixG/bdc299b939dbbd455795 to your computer and use it in GitHub Desktop.
Drift
stock GetVehicleDriftAngle(vehicleid, &Float:fVehDriftAngle)
{
new
Float: fVehVelocity[3],
Float: fVehAngle,
Float: fVehMoveAngle;
if (!GetVehicleVelocity(vehicleid, fVehVelocity[0], fVehVelocity[1], fVehVelocity[2]))
{
return 0;
}
if (fVehVelocity[0] == 0.0 && fVehVelocity[1] == 0.0)
{
fVehDriftAngle = 0.0;
return 1;
}
fVehMoveAngle = -atan2(fVehVelocity[0], fVehVelocity[1]);
GetVehicleZAngle(vehicleid, fVehAngle);
if (fVehAngle > 180.0)
{
fVehAngle -= 360.0;
}
fVehDriftAngle = fVehMoveAngle - fVehAngle;
if (fVehDriftAngle < -180.0)
{
fVehDriftAngle += 360.0;
}
else if (fVehDriftAngle > 180.0)
{
fVehDriftAngle -= 360.0;
}
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment