I'm looking to rotate a gui with a particular point acting as the center of rotation. Unfortunately I don't know how to go about doing this... Here's an image depicting the situation: http://i.imgur.com/xPkPbzL.jpg
Obligatory code:
function rotateFromPoint(gui, x,y, angle) --x,y being the point on the gui (0,0 being corner) --and here I haven't a clue how to offset the rotation point and all that jazz. end
If you took trigonometry, you would know that in a Unit Circle
, the coordinate of any point on that circle is equal to (Cos(Angle),Sin(Angle))
. "Angle" being the angle of the line drawn from (0,0)
to the coordinate of the point. So in order to rotate a Gui around a point, you would have to code it like this:
function rotateFromPoint(Gui,X,Y,Angle,Radius) local XPos = X + math.cos(Angle) * Radius local YPos = Y + math.sin(Angle) * Radius Gui.Position = UDim2.new(0,XPos,0,YPos) end
Hope this helped!
Note: XPos
and YPos
are going to be the offset values, not the scale values.
Link(s): Unit Circle