Help me improve my car!

the script that makes my car move is a very simple script, all it does is make the car move and makes sure when the player exits the car, it stops. but what i don’t like is how the turning is really bad. I’ll show my code and the VS Properties (VehicleSeat) if you think i need to change the RIGGING of the car and change the cylindrical and spring, constraints, tell me and I’ll be glad to show you the properties!
VehicleSeat Propertys:
image

Also a picture of how the car rigging looks like:

--Variables
local car = script:WaitForChild("Car").Value
local char = game.Players.LocalPlayer.Character
local human
local stop = script:WaitForChild("Stop")
local seat = car.Body.VehicleSeat
local heartbeat
--These are variables for the attachments of the car,
local attFL = car.Chassis.Platform.AttachmentFL
local attFR = car.Chassis.Platform.AttachmentFR
local attBL = car.Chassis.Platform.AttachmentBL
local attBR = car.Chassis.Platform.AttachmentBR
local CylBL = car.Chassis.Platform.CylindricalBL
local CylBR = car.Chassis.Platform.CylindricalBR
local CylFL = car.Chassis.Platform.CylindricalFL
local CylFR = car.Chassis.Platform.CylindricalFR
local ms = 30
local steer = 0
local throttle = 0
local ms = 30

local function Update(dt)
	--Steer;
--In general, all this math stuff is so that the steering is smooth and it also has ackerman Steering, here is a video you can watch on it if you don't know what it is: https://www.youtube.com/watch?v=z-nudIXKpkM&t=1s
	local goal = -seat.SteerFloat * ms
	steer = steer + (goal - steer) * math.min(dt * seat.TurnSpeed, 1)
	local radians = math.rad(90 - math.abs(steer))
	local h = -(attFR.WorldPosition - attBR.WorldPosition).Magnitude
	local z = (attBR.WorldPosition - attBL.WorldPosition).Magnitude
	local x = math.tan(radians) * h
	local y = (x + z)
	local OTA = 90 - math.deg(math.atan2(y, h))
	if (steer > 0)then
		attFL.Orientation = Vector3.new(0, OTA, 90)
		attFR.Orientation = Vector3.new(0, steer, -90)
	else
		--r
		OTA = -OTA
		attFL.Orientation = Vector3.new(0,OTA,90)
		attFR.Orientation = Vector3.new(0,steer,-90)
end
--The throttle is more simple, it has some math stuff to make it more smooth, but other then that its not that complicated just setting values 
	--Throttle;
	local ThrottleGoal = seat.ThrottleFloat
	throttle = throttle + (ThrottleGoal - throttle) * math.min(dt * seat.TurnSpeed, 1)
	local Torque = seat.Torque
	local speed = seat.MaxSpeed * throttle
	CylBL.MotorMaxTorque = Torque
	CylBR.MotorMaxTorque = Torque
	CylFL.MotorMaxTorque = Torque
	CylFR.MotorMaxTorque = Torque
	CylBL.AngularVelocity = speed
	CylBR.AngularVelocity = -speed
	CylFL.AngularVelocity = speed
	CylFR.AngularVelocity = -speed
	

end

local function Start()
	print("Start Client")
	heartbeat = game:GetService("RunService").Heartbeat:Connect(Update)
	
end
local function Stop()
	print("Stop Client")
	script:Destroy()
	heartbeat:Disconnect()
	script:Destroy()
end

if (stop.Value) then Stop() return end
Start()
local function chagning(sit,seated)
	if seated then
		seat.MaxSpeed = 60
	else
		seat.MaxSpeed = 0
	end
end
human = char:FindFirstChild("Humanoid")
human.Seated:Connect(chagning)
stop.Changed:Connect(function(shouldStop)
	if (not shouldStop) then return end
	Stop()
end)


and, a video of what i’m talking about when i say the “turning is bad”
Video - YouTube

2 Likes

All wheel drive doesn’t let you turn sharp, the tutorial you followed in which I know, they tell you that it’s in all-wheel drive. The front wheel drive hinges should have the set ActuatorType to None.

3 Likes