If you’re not familiar with Ackermann Steering, it’s basically steering the car around a rotation point
So the left and right wheel will never turn at the exact same angle, like in the picture.
I saw Sleitnick’s twitter post on how to do it, and used his code but changed it up a bit to make it fit for my own vehicle.
In this video you can see where this kinda goes wrong, and i got no idea on how to fix it.
https://i.gyazo.com/d67c25df5cfda2f1c7de5e78b09d2a26.mp4
Code:
local function Ackermann(degrees, h, z)
local Rads = math.rad(90 - math.abs(degrees))
local x = math.tan(Rads) * h
local y = (x + z)
local OuterTurnAngle = 90 - math.deg(math.atan2(y, h))
local Left
local Right
if degrees ~= 90 then
if degrees > 90 then
Left = degrees
Right = OuterTurnAngle
else
Left = OuterTurnAngle
Right = degrees
end
else
Left = 90
Right = 90
end
return Left, Right
end
local Info = TweenInfo.new(.5)
local LeftOrientation, RightOrientation = Ackermann(90 - SeatPart.SteerFloat * SeatPart.TurnSpeed, h, z)
--print(LeftOrientation, RightOrientation)
TweenService:Create(FLwheelConstraint, Info, {Orientation = Vector3.new(-0, LeftOrientation, FRwheelConstraint.Orientation.Z)}):Play()
TweenService:Create(FRwheelConstraint, Info, {Orientation = Vector3.new(-0, RightOrientation, FRwheelConstraint.Orientation.Z)}):Play()
Any help is appreciated, thanks!