I want to rotate the wheels of a bike with CFrame.Angles. However, when I try to do this at faster speeds the wheels start moving position aswell. I’m rotating using the model’s pivot which might be the issue.
while true do
workspace.SingleWheel:PivotTo(workspace.SingleWheel:GetPivot() * CFrame.Angles(0,0,math.deg(.001)))
task.wait()
end
Your issue is that PivotTo moves the entire model’s pivot. Each multiplication with CFrame.Angles is applied in world space, and small floating-point errors accumulate. That’s why the wheel drifts instead of only spinning.
This may work..
local front = workspace.Bike.FrontWheel
local back = workspace.Bike.BackWheel
local baseFront = front:GetPivot()
local baseBack = back:GetPivot()
local a = 0
while true do
a += 0.1
front:PivotTo(baseFront * CFrame.Angles(0,0,a))
back:PivotTo(baseBack * CFrame.Angles(0,0,a))
task.wait()
end
Not sure how you’re moving the bike so..
local bike = workspace.Bike
local front = bike.FrontWheel
local back = bike.BackWheel
local baseFront = front:GetPivot()
local baseBack = back:GetPivot()
local aFront, aBack = 0, 0
local radius = 2 -- set this to match the actual wheel radius
while true do
local vel = bike.PrimaryPart.AssemblyLinearVelocity.Magnitude
local rot = vel / radius
aFront += rot
aBack += rot
front:PivotTo(baseFront * CFrame.Angles(0,0,aFront))
back:PivotTo(baseBack * CFrame.Angles(0,0,aBack))
task.wait()
end