Is this line of code valid?

i am just trying to move a part in a circle

but is this line of code normal to move my part in a circle (wrapped in a loop/RunService.Heartbeat)

part.CFrame = part.CFrame:Lerp(CFrame.new(Vector3.new(math.sin(i)*10^2, part.Position.Y, math.cos(i)*10^2)), 0.01)
2 Likes

nope. this line of code IS NOT valid. bad job

instead of doing the alpha as 0.01, use 0.01 * (dt * 60)
so it changes depending on fps. always use dt * 60 in your alpha’s and never change it, only change 0.01

also depending on your i you sohuld cache the result of sin and cosine

also instead of doing 10^2 either define it as a variable or js type 100

But maybe his game is capped at 60FPS

1 Like

no because what if a players running at 40fps on their 20yo netbook. then the dt * 60 would adjust the lerp alpha so that its as fast as if it were lerping on a 60fps machine

also players can uncap their fps to 120. simialrly the dt * 60 slows down their lerp so that it matches that of a 60fps device

hope that makes sense

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.