SHARE
TWEET

getVehicleDriftAngle

StrixG Nov 4th, 2014 (edited) 25 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getVehicleDriftAngle(theVehicle)
  2.         if getElementType(theVehicle) ~= "vehicle" then
  3.                 return false
  4.         end
  5.  
  6.         local vX, vY = getElementVelocity(theVehicle)
  7.         if (vX == 0.0 and vY == 0.0) then
  8.                 return 0.0
  9.         end
  10.  
  11.         local rotX, rotY, rotZ = getElementRotation(theVehicle)
  12.        
  13.         local moveDirection = math.deg(-math.atan2(vX, vY))
  14.  
  15.         if rotZ > 180 then
  16.                 rotZ = rotZ - 360
  17.         end
  18.        
  19.         local driftAngle = moveDirection - rotZ;
  20.  
  21.         if driftAngle < -180.0 then
  22.                 driftAngle = driftAngle + 360.0
  23.         elseif driftAngle > 180.0 then
  24.                 driftAngle = driftAngle - 360.0
  25.         end
  26.         return driftAngle
  27. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top