I’m trying to re-create an old style of vehicle turning, where steering causes one side to reverse direction instead of the wheels changing angle. (The yellow bits are just suspension stuff, they don’t affect the build.)
I’ve got it working, but when I steer, the throttle input shuts off until I press it again, making a super uncomfortable driving experience. (In other words: Throttle on + steer either way = throttle off (until it’s pressed again))
I’ve looked up countless tutorials and even tried out alternatives using free models but nothing’s working out.
I’ve done this with my treaded vehicles and on my 8 wheel drive suspension vehicle (script from that one below). You have to have inputs that recognize when both Throttle and Steering are inputted and change the wheel speeds accordingly.
For example, if the inputs are Fwd and Left then your right wheel’s AngularVelocity should be 2, but your left wheel’s AngularVelocity should be less than that. Fine tune it to get the steering feel you want.
I’m not great at scripting, so my scripts go through and check for each type of input, then set the AngularVelocities for each wheel. There’s probably a cleaner way, but this works.
You can copy scripts directly here, just add 3 backward apostrophes before and after your script so it formats it properly:
seat = script.Parent.VehicleSeat
local St = script.Parent.Wheels
local l1 = script.Parent.Bodykit.L1.HingeConstraint
local l2 = script.Parent.Bodykit.L2.HingeConstraint
local l3 = script.Parent.Bodykit.L3.HingeConstraint
local l4 = script.Parent.Bodykit.L4.HingeConstraint
local r1 = script.Parent.Bodykit.R1.HingeConstraint
local r2 = script.Parent.Bodykit.R2.HingeConstraint
local r3 = script.Parent.Bodykit.R3.HingeConstraint
local r4 = script.Parent.Bodykit.R4.HingeConstraint
local h = 16
local l = 2
seat.Changed:connect(function()
if seat.Steer == 0 or seat.Steer == nil and seat.Throttle == 0 then --stop
l1.AngularVelocity = 0
l2.AngularVelocity = 0
l3.AngularVelocity = 0
l4.AngularVelocity = 0
r1.AngularVelocity = 0
r2.AngularVelocity = 0
r3.AngularVelocity = 0
r4.AngularVelocity = 0
end
if seat.Steer == 0 and seat.Throttle == 1 then --forwards
l1.AngularVelocity = h
l2.AngularVelocity = h
l3.AngularVelocity = h
l4.AngularVelocity = h
r1.AngularVelocity = h
r2.AngularVelocity = h
r3.AngularVelocity = h
r4.AngularVelocity = h
end
if seat.Steer == 0 and seat.Throttle == -1 then --backwards
l1.AngularVelocity = -h
l2.AngularVelocity = -h
l3.AngularVelocity = -h
l4.AngularVelocity = -h
r1.AngularVelocity = -h
r2.AngularVelocity = -h
r3.AngularVelocity = -h
r4.AngularVelocity = -h
end
------------------------------------------------------------------------------------------
if seat.Steer == 1 and seat.Throttle == 1 then --forwards and turn R
l1.AngularVelocity = h
l2.AngularVelocity = h
l3.AngularVelocity = h
l4.AngularVelocity = h
r1.AngularVelocity = l
r2.AngularVelocity = l
r3.AngularVelocity = l
r4.AngularVelocity = l
end
if seat.Steer == 1 and seat.Throttle == 0 then --turn R
l1.AngularVelocity = l
l2.AngularVelocity = l
l3.AngularVelocity = l
l4.AngularVelocity = l
r1.AngularVelocity = -l
r2.AngularVelocity = -l
r3.AngularVelocity = -l
r4.AngularVelocity = -l
end
if seat.Steer == 1 and seat.Throttle == -1 then --backwards and turn R
l1.AngularVelocity = -h
l2.AngularVelocity = -h
l3.AngularVelocity = -h
l4.AngularVelocity = -h
r1.AngularVelocity = -l
r2.AngularVelocity = -l
r3.AngularVelocity = -l
r4.AngularVelocity = -l
end
------------------------------------------------------------------------------------------
if seat.Steer == -1 and seat.Throttle == 1 then --forwards and turn left
l1.AngularVelocity = l
l2.AngularVelocity = l
l3.AngularVelocity = l
l4.AngularVelocity = l
r1.AngularVelocity = h
r2.AngularVelocity = h
r3.AngularVelocity = h
r4.AngularVelocity = h
end
if seat.Steer == -1 and seat.Throttle == 0 then --turn left
l1.AngularVelocity = -l
l2.AngularVelocity = -l
l3.AngularVelocity = -l
l4.AngularVelocity = -l
r1.AngularVelocity = l
r2.AngularVelocity = l
r3.AngularVelocity = l
r4.AngularVelocity = l
end
if seat.Steer == -1 and seat.Throttle == -1 then --backwards and turn left
l1.AngularVelocity = -l
l2.AngularVelocity = -l
l3.AngularVelocity = -l
l4.AngularVelocity = -l
r1.AngularVelocity = -h
r2.AngularVelocity = -h
r3.AngularVelocity = -h
r4.AngularVelocity = -h
end
end)
This isn’t working, but I’ll try putting this concept into my old script. The “h”, “l” thing didn’t work out, so I replaced it with maxSpeed, but to no avail.
local fldrive = script.Parent.Parent.WheelFL.FLAxle.FLHub
local frdrive = script.Parent.Parent.WheelFR.FRAxle.FRHub
local rldrive = script.Parent.Parent.WheelRL.RLAxle.RLHub
local rrdrive = script.Parent.Parent.WheelRR.RRAxle.RRHub
local maxSpeed = 100
seat.Changed:connect(function()
if seat.Steer == 0 or seat.Steer == nil and seat.Throttle == 0 then --stop
fldrive.AngularVelocity = 0
frdrive.AngularVelocity = 0
rldrive.AngularVelocity = 0
rrdrive.AngularVelocity = 0
end
if seat.Steer == 0 and seat.Throttle == 1 then --forwards
fldrive.AngularVelocity = maxSpeed
frdrive.AngularVelocity = maxSpeed
rldrive.AngularVelocity = maxSpeed
rrdrive.AngularVelocity = maxSpeed
end
if seat.Steer == 0 and seat.Throttle == -1 then --backwards
fldrive.AngularVelocity = -maxSpeed
frdrive.AngularVelocity = -maxSpeed
rldrive.AngularVelocity = -maxSpeed
rrdrive.AngularVelocity = -maxSpeed
end
------------------------------------------------------------------------------------------
if seat.Steer == 1 and seat.Throttle == 1 then --forwards and turn R
fldrive.AngularVelocity = maxSpeed
frdrive.AngularVelocity = maxSpeed
rldrive.AngularVelocity = maxSpeed * 0.5
rrdrive.AngularVelocity = maxSpeed * 0.5
end
if seat.Steer == 1 and seat.Throttle == 0 then --turn R
fldrive.AngularVelocity = maxSpeed
frdrive.AngularVelocity = maxSpeed
rldrive.AngularVelocity = -maxSpeed
rrdrive.AngularVelocity = -maxSpeed
end
if seat.Steer == 1 and seat.Throttle == -1 then --backwards and turn R
fldrive.AngularVelocity = -maxSpeed * 0.5
frdrive.AngularVelocity = -maxSpeed * 0.5
rldrive.AngularVelocity = -maxSpeed
rrdrive.AngularVelocity = -maxSpeed
end
------------------------------------------------------------------------------------------
if seat.Steer == -1 and seat.Throttle == 1 then --forwards and turn left
fldrive.AngularVelocity = maxSpeed * 0.5
frdrive.AngularVelocity = maxSpeed * 0.5
rldrive.AngularVelocity = maxSpeed
rrdrive.AngularVelocity = maxSpeed
end
if seat.Steer == -1 and seat.Throttle == 0 then --turn left
fldrive.AngularVelocity = -maxSpeed
frdrive.AngularVelocity = -maxSpeed
rldrive.AngularVelocity = maxSpeed
rrdrive.AngularVelocity = maxSpeed
end
if seat.Steer == -1 and seat.Throttle == -1 then --backwards and turn left
fldrive.AngularVelocity = -maxSpeed
frdrive.AngularVelocity = -maxSpeed
rldrive.AngularVelocity = -maxSpeed * 0.5
rrdrive.AngularVelocity = -maxSpeed * 0.5
end
end)```
I used “h” and “l” as variables so that if I wanted to fine tune the steering I only needed to change the High and Low variables in one location rather than change it in 72 places. So much easier.
My script was just an example of how I did it, so yes, you’d have to set your script up similar.
Closing this subject, nothing is working even after getting help from multiple friends and even re-doing it several times with different models. I’ve scrapped the project out of frustration.
If you want send me a copy of the model with the script in it and I can have a look.
It shouldn’t be that hard to have it work, it may just be some small detail that you are unaware of.