Using roblox physics to "rotate" around a pivot

Hi, I want to be able to move a part at a constant speed around a “pivot” like so:

I don’t want to use scripting for it (i.e. I just want to use the mechanical constraints provided by Roblox like AngularVelocity etc.)

How can I do this? Thanks.

1 Like

try this function:

local speed = 2
local Distance = 0
local angle = 0
local function movePartB(PartA,PartB,dt)
    local mag = ((partA.Position - partB.Position).Magnitude)
    angle = (angle + dt * (math.pi * speed)) % (2 * math.pi)
    partB.CFrame = partA.CFrame * CFrame.new((math.cos(angle) * mag), -Distance, math.sin(angle) * mag)
end

Use it inside a RunService function and pass the deltaTime as dt
PartA: is the part that is static.
PartB: is the part that is rotating.

Usage:

game:GetService("RunService").Heartbeat:Connect(function(dt)
   movePartB(PartA,PartB,dt)
end)
1 Like