Ackermann steering not completely working

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!

Looks like an issue with your car’s physics. Make sure that your car can properly move.

I don’t think the problem is with the physics, it all works well

Sorry for bumping a two year old post, but I’m having the same issue - It’s not working for me either:

AckermanNotWorking.rbxl (59.4 KB)

To adjust the angle, go to Attempt2 → HingeConstraint → TargetAngle

1 Like
innerAngle = math.atan(1/(math.cos(outerAngle)/math.sin(outerAngle))+(wheelBase/track))

wheelbase is distance between front and rear axle/wheels
track is the distance between the left and right hubs

Alrighty… this is getting me somewhere :D

What is “hubs”? is it the point at which the wheel pivots? the kingpin? Thanks!

Also, why does yours work, but mine doesn’t?

Edit: What can I change in my file that’ll fix the geometry?


I have my geometry correct, right?