I attempted to make kart wheels rotatable with motor6ds. But the result wasn’t like what I expected
part welds and script:
--update
--wheels
local ForwardSpeed = MaxSpeed.Movement.Max.Value * BoostMultipler
local BackwardSpeed = MaxSpeed.Movement.Min.Value * BoostMultipler
local HitboxVel = Main.Hitbox.Velocity
local ClampedVel = math.clamp(HitboxVel.Z, -BackwardSpeed, ForwardSpeed)
local AbsoluteVel = math.abs(ClampedVel)
CurrentWheelSpeed = AbsoluteVel <= 0.5 and ClampedVel or CurrentWheelSpeed
local SpeedFromThrottle = 0
if ThrottleFloat ~= 0 then
SpeedFromThrottle = ThrottleFloat < 0 and BackwardSpeed or ForwardSpeed
end
local OverallSpeed = SpeedFromThrottle * ThrottleFloat
CurrentWheelSpeed = CurrentWheelSpeed + (OverallSpeed - CurrentWheelSpeed) * dt
for i, v in pairs(Body.Wheels:GetChildren()) do
local name = v.Name:lower()
if not name:match("fixed") then
local v1 = tostring(v.Name)
local v2 = v1:sub(7, 7)
local v3 = WheelThrottleTable[v1:lower()]
local v4 = (v3 + dt * CurrentWheelSpeed / (v.Core.WheelWeld.Part1.Size.Y * math.pi)) % 4
v3 = v4
--find front wheels
--[[if v2 == "F" then
v.Core.WheelWeld.C1 = CFrame.new(v.Core.WheelWeld.C1.Position) * (CFrame.Angles(v4 * (math.pi * 2), 0, 0) * CFrame.Angles(0, not Stats.NoWheelTurn.Value and -math.rad(45 * SteerFloat) or 0, 0)) --CFrame.Angles(-v4 * (math.pi * 2), not Stats.NoWheelTurn.Value and -math.rad(45 * SteerFloat) or 0, 0):Inverse() + v.Core.WheelWeld.C1.Position --v.Core.WheelWeld.C1 * CFrame.Angles(v4 * (math.pi * 2), not Stats.NoWheelTurn.Value and math.rad(45 * SteerFloat) or 0, 0)
else
v.Core.WheelWeld.C1 = CFrame.new(v.Core.WheelWeld.C1.Position) * (CFrame.Angles(v4 * (math.pi * 2), 0, 0)) --CFrame.Angles(-v4 * (math.pi * 2), 0, 0):Inverse() + v.Core.WheelWeld.C1.Position --v.Core.WheelWeld.C1 * CFrame.Angles(v4 * (math.pi * 2), 0, 0)
end]]
if v2 == "F" then
v.Core.WheelWeld.C1 = CFrame.new(v.Core.WheelWeld.C1.Position) * CFrame.Angles(0, not Stats.NoWheelTurn.Value and -math.rad(45 * SteerFloat) or 0, 0)
end
v.Core.WheelWeld.C1 = v.Core.WheelWeld.C1 * CFrame.Angles(v4 * (math.pi * 2), 0, 0)
end
end
--
The outcome:
I browsed through this page and could not find the topics with exact same problems as mine. So I wrote this to see whether someone can figure out