Hello
I am trying to create a pendulum motion by using the roblox physics and not CFrame or Position.
I found some tutorials on how to do that with cframes/positions however I cannot find a way to use a force to do it.
local Bob = workspace.Pendulum.Bob
local Origin = workspace.Pendulum.Origin
local run = game:GetService("RunService")
local length = (Origin.Position - Bob.Position).magnitude
local theta = math.rad(45)
local AngVelocity = math.rad(1)
run.Heartbeat:Connect(function()
local XArc = length * math.sin(theta)
local YArc = length * math.cos(theta)
Bob.BodyPosition.Position = Vector3.new(XArc, YArc, 0) + Origin.Position
AngVelocity = (AngVelocity + (0.01*math.sin(theta)))
theta = theta + AngVelocity
end)
This is the result I am getting:
This is what I want to happen:
All I changed in the code is
local theta = math.deg(45)
Bob.Position = Vector3.new(XArc, YArc, 0) + Origin.Position