Возвращает угол и направление заноса транспортного средства
float getVehicleDriftAngle ( element theVehicle )
function getVehicleDriftAngle(theVehicle)
if getElementType(theVehicle) ~= "vehicle" then
return false
end
local vX, vY = getElementVelocity(theVehicle)
if (vX == 0.0 and vY == 0.0) then
return 0.0
end
local rotX, rotY, rotZ = getElementRotation(theVehicle)
local moveDirection = math.deg(-math.atan2(vX, vY))
if rotZ > 180 then
rotZ = rotZ - 360
end
local driftAngle = moveDirection - rotZ;
if driftAngle < -180.0 then
driftAngle = driftAngle + 360.0
elseif driftAngle > 180.0 then
driftAngle = driftAngle - 360.0
end
return driftAngle
end
http://pastebin.com/T8xzNcDD