Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is there an easier way to make sine animations, why does it have to be so complicated?

Hello, I'm a scripter.

I've been using sine operations to animate in all my scripts lately. If you're someone who doesn't know what sine is, it's basically a wave operation that can be used to create animations like this one below.

https://gyazo.com/03f90e00370ccc97b0e3dda87ca2e349

Here's my sample code. Using the c-lerp method, which is a little more dependable than the lerp function, I can create animations that have no choppy effects.

RH.C0 = clerp(RH.C0,CFrame.new(1,-1,0) * CFrame.Angles(math.rad(0),math.rad(90),math.rad(0)),.1)
LH.C0 = clerp(LH.C0,CFrame.new(-1,-1,0) * CFrame.Angles(math.rad(0),math.rad(-90),math.rad(0)),.1)
RootJoint.C0 = clerp(RootJoint.C0,RootCFrame * CFrame.new(0,0,0) * CFrame.Angles(math.rad(0),math.rad(0),math.rad(0)),.1)
Torso.Neck.C0 = clerp(Torso.Neck.C0,NeckMotor6DCFrame_1 * CFrame.Angles(math.rad(0),math.rad(0),math.rad(0)),.1)
RW.C0 = clerp(RW.C0,CFrame.new(1.5,.5,0) * CFrame.Angles(math.rad(0),math.rad(0),math.rad(0)),.1)
LW.C0 = clerp(LW.C0,CFrame.new(-1.5,.5,0) * CFrame.Angles(math.rad(0),math.rad(0),math.rad(0)),.1)

Now down to my question, is it possible to animate easier using this operation? I am not planning to use the Roblox animator, either way, that animator would not be able to transfer keyframes into wave values.

I appreciate all answers, if you think you have a possible lead to my question, please respond to this question, thank you.

1 answer

You can use the TweenService

Like this:

local TweenService = game:GetService("TweenService")
 
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Color = Color3.new(1, 0, 0)
part.Anchored = true
part.Parent = game.Workspace
 
local goal = {}
goal.Position = Vector3.new(10, 10, 0)
goal.Color = Color3.new(0, 1, 0)
 
local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
 
local tween = TweenService:Create(part, tweenInfo, goal)

I didn't know CFraming was an option lol

If you want more information the article is here: https://developer.roblox.com/en-us/api-reference/class/Tween

1 comment

0

Keep in mind, I'm playing around with joints (Motor6D specifically), there's only a good amount of code I can write before I begin to experience lag.

This discussion is preserved as it was. New answers, comments, and votes are closed.