Hi, I just wanted to know if it was possible to make a UI move in a circular motion like the sun/moon cycle in Terraria. I want an imagelabel to go around the circumference of the circle. I have no clue how this can be done.

2 Likes

You can do that with a bezier curve. You would make 3 points just off to the left, top and right of the screen, and then just lerp the sun:

```
local run = game:GetService("RunService")
local sun = script.Parent.Frame
--create the 3 points
local p1 = UDim2.fromScale(-0.2,0.4)
local p2 = UDim2.fromScale(0.5,-0.2)
local p3 = UDim2.fromScale(1.2,0.4)
local function lerp(t)
local cumulative = 0
while cumulative < t do
cumulative += run.Heartbeat:Wait()
--make sure we use time scale from 0-1
local d = cumulative/t
--get current positions from p1 to p2 and from p2 to p3
local x = p1:Lerp(p2,d)
local y = p2:Lerp(p3,d)
--set the sun's position to current position from x to y
sun.Position = x:Lerp(y,d)
end
end
--you can send the length of the animation or simply have it as a variable somewhere above
lerp(10)
```

this is too inefficient, you’re better off using sin & cos

You could just rotate with:

```
x=math.sin(time)
y=math.cos(time)
```

or if it rotates the orther direction then:

```
x=math.cos(time)
y=math.sin(time)
```

1 Like