Hello roblox devs,
I have found a non-physics based pendulum tutorial, it works well however I dont want it to use a CFrames but rather a BodyVelocity.
The tutorial: Making a simple Pendulum Model without physics
In the tutorial its stated by the creator you can derive the velocity from it myself and use a BodyVelocity, but im still unsure how I do that… ive tried searching more about the BodyVelocity and a pendulum motion but I am not able to find a way to make it work.
local Bob = workspace.Bob
local Origin = workspace.Origin
local Length = (Origin.Position - Bob.Position).magnitude
local a = Origin.Position.X - Bob.Position.X
local c = Origin.Position.Y - Bob.Position.Y
local theta = math.asin(a/c) --I have changed this simply because I dont want to have a default set angle but rather find it out and use that angle in the pendulum since I will have different angles all the time in my main code I want to implement this pendulum system into.
local angVel = 0
local function Compute()
local XArc = Length * math.sin(theta)
local YArc = Length * math.cos(theta)
Bob.BodyVelocity.Velocity = Vector3.new(XArc , YArc, 0) --Bob has a BodyVelocity instance.
angVel = (angVel + (0.01*math.sin(theta)))
theta = theta + angVel
end
local run = game:GetService("RunService")
run.Heartbeat:Connect(Compute)
Could anyone please explain to me the math behind this? How do I use the BodyVelocity to create a pendulum motion?