Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement