I’ve been trying to learn how to make a pendulum motion by this post and some knowledge i’ve acquired by Khan Academy.
The problem is I can’t properly dampen a the motion of this bob around the origin.
local RunService = game:GetService("RunService")
local radius = 12
local bob = script.Parent
local origin = workspace.Origin
local angle = 0
local vel = 0
local speed = 3
local drag = 0.5
RunService.Heartbeat:Connect(function(delta)
angle += .01
vel = vel + (delta * drag * speed) + math.sin(delta)
local c = radius * math.cos(vel)
local s = radius * math.sin(vel)
bob.CFrame = origin.CFrame * CFrame.new(c,s,0)
end)
My current code above moves the bob in a constant circle in which it is not like pendulum motion. I’m trying to acquire pendulum motion like in the post above.