Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function MoveBasedOnOrientation(pUnit, orientation, yards)
- 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
- 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
- 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
- -- 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?)
- pUnit:MoveTo(pUnit:GetX()+UNIT_X, pUnit:GetY()+UNIT_Y, pUnit:GetLandHeight(pUnit:GetX()+UNIT_X, pUnit:GetY()+UNIT_Y), pUnit:GetO())
- -- moving to new location, use GetLandHeight to get the height of the new location to prevent clipping (going through the ground)
- end
Advertisement
Add Comment
Please, Sign In to add comment