BTW, using SetUnitX and SetUnitY is better than SetUnitPosition(newX, newY)?
SetUnitPosition() has its own quirks. SetUnitPosition() has pathing checks and will interrupt orders/animations. SetUnitX/Y() will retain orders/animations, but will not check pathing.
Because of the extra pathing checks, SetUnitPosition() becomes pretty slow.
Wow! Thank you all for your replies.
@Chaosy
That's what I use right now, but I'm looking to expand my knowledge and also retain orders the moving unit has.
@Spartipilo
Is there some place to learn these "maths", I'm mainly looking to move the unit in a straight line so I figured it would be pretty easy xD
@MasterTrainer
If I save my unit to a variable would I just change GetTriggerUnit() to udg_myUnit?
For the final question, yes you can just save it to a variable and replace GetTriggerUnit() with udg_<Variable Name>.
As for the question on how to learn the maths, you usually figure it out by looking at examples. This tutorial is pretty old, but it has solid information:
http://www.thehelper.net/threads/graphics-dynamic-effects-gui.35362/
You can also look up the GUI - JASS equivalents of certain calculations, such as DistanceBetweenUnits, AngleBetweenPoints, and polar position.
When you set a unit's position with an offset it is:
originalX + distance * Cos(some angle) = newX
originalY + distance * Sin(some angle) = newY
<some angle> should be in radians. If it is in degrees, you can multiply it by bj_DEGTORAD, or pi/180. This basically will get the new coordinates of a point, offset by some distance towards some angle.
You don't learn all of this stuff in normal math classes. You'll learn most of these concepts, but might not be able to put two and two together that easily. You learn the distance formula really early (I think Algebra 2), which is basically DistanceBetweenUnits(). AngleBetweenPoints() you'll also learn in either Geometry or Algebra2, but the form it is in [Atan2()], you might not be familiar with. Polar position you tend to learn in Calculus BC/college level calculus. You may be introduced to it earlier, though.
Basically, the point of that^ paragraph above is to say that it is kind of scattered information. Play around with it, and you'll begin to learn why certain things happen. Just look at examples. Don't be afraid to look up a slide or knockback in our spells section--there should be tons of them.