stoneharry

Untitled

Mar 9th, 2012
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. function MoveBasedOnOrientation(pUnit, orientation, yards)
  2.     local UNIT_RADIANS = RADIAN_START + orientation -- WoW's orientation is a radian, because WoW's circle starts at the top we need the radian_start to make sure we're counting from the top
  3.     local UNIT_Y = math.cos(UNIT_RADIANS)*-yards -- WoW has switched the x and y axis, x is from bottom to top, y from right to left
  4.     local UNIT_X = math.sin(UNIT_RADIANS)*yards -- meaning y counts up if going to left, counts down if going to right, x counts up top, bottom: down
  5.     -- multiply by the yards we want to move as it'll return a number based on a circle which consists of 1 to each side (unit circle?)
  6.     pUnit:MoveTo(pUnit:GetX()+UNIT_X, pUnit:GetY()+UNIT_Y, pUnit:GetLandHeight(pUnit:GetX()+UNIT_X, pUnit:GetY()+UNIT_Y), pUnit:GetO())
  7.     -- moving to new location, use GetLandHeight to get the height of the new location to prevent clipping (going through the ground)  
  8. end
Advertisement
Add Comment
Please, Sign In to add comment