Why does my pivoting block sink over multiple iterations? I’m a bit lost on the math for this one I want it to be able to roll across a flat plane.
local Part: Part = game.Workspace.ROLL -- The demensions are the same; 10x10x10
local cycles: number = 8
for i=1, cycles do
local Pivot: CFrame = Part.CFrame - Vector3.new(0,Part.Size.Y/2,0)
local Offset: CFrame = Pivot:Inverse() * Part.CFrame
Pivot *= CFrame.Angles(math.rad(90/cycles),0,0)
Part.CFrame = Pivot * Offset
task.wait()
end
UPDATE: Here’s a hacky fix for it, but I’m hoping someone has the real math solution.
local Part: Part = game.Workspace.ROLL -- The demensions are the same; 10x10x10
local cycles: number = 10
for i=1, cycles do
local originY = Part.CFrame.Y
local Pivot: CFrame = Part.CFrame - Vector3.new(0,(Part.Size.Y/2),0)
local Offset: CFrame = Pivot:Inverse() * Part.CFrame
Pivot *= CFrame.Angles(math.rad(90/cycles),0,0)
local newCFrame = Pivot * Offset
local yDelta = originY - newCFrame.Y -- Hacky way to fix the block sinking otherwise...
Part.CFrame = newCFrame + Vector3.new(0,yDelta,0)
task.wait()
end