Help with rotation effects

How would I recreate this rotation effect?

I’m not sure if its linear or something else, but please could someone help me with this!

Use CFrame:Lerp to rotate the tower smoothly.

Or TweenService. If your code runs in a loop, lerping is better, but if it runs on events, use tweens.

1 Like

It’s definitely in a loop because the tower is moving based on the mouse’s position.

1 Like

what is the difference between lerp and tween service?? i got no idea, i tried searching it up, people say its the same

Yes, that’s why both work. He can either set a rotate variable every time he presses the button and use that to lerp the character, or he can tween once when he presses the button.

My bad, I forgot this was for rotation and not for position :tongue:

Lerping or “Linear Interpolation” is a way to get a point BETWEEN two other points at a given fragment.

Lets say, you have point A and point B. You want to get a point which is halfway from A to B, you can do this:

C = A:Lerp(B, 0.5) -- you want it HALFway so you put 0.5 as the second argument

And lets say, you want to get point D which is still between A and B, but D is not halfway from A to B, but is closer to one of them. For example, you want it to be 3/4 towards A and only 1/4 towards B, you can do this:

D = A:Lerp(B, 0.25) -- the second argument is 0.25 since you want point D to be at the QUARTER-way from A to B

(The second argument should be a number between 0 and 1, where 0 is at A and 1 is at B)

You can use lerping in a loop where you constantly increase the second argument, making it look smooth like an animation.

The TweenService is just a way to make animations for any property of an instance, such as position, transparency, colour or even Value (anything that is a number), and also lets you use different easing styles. You can read more on the official documentation.

I hope this helps!

4 Likes

ooh, that’s helpful, i knew about tween service, but i thought lerp is just the same

I used tween service. Thank you for all ur help.

2 Likes

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