I’m trying to make a wheel turn but it’s just not working.
Video ;
Script ;
-- server script
local RunService = game:GetService('RunService')
local Folder = workspace.Cars
RunService.Stepped:Connect(function()
for _, Car:Model in Folder:GetChildren() do
local DriverSeat:VehicleSeat = Car.Seats:FindFirstChildWhichIsA('VehicleSeat')
if not DriverSeat then continue end
for _, Wheel:BasePart in Car.Wheels:GetChildren() do
Wheel.Rim.HingeConstraint.AngularVelocity = DriverSeat.Throttle * 50
if Wheel:FindFirstChild('Servo') then
Wheel.Servo.HingeConstraint.TargetAngle = (DriverSeat.Steer * 30)
print(Wheel.Servo.HingeConstraint.TargetAngle)
end
end
end
end)
Crank the torque waaaay up. For my steering I use something around 1,000,000,000. I find that using values at inf seems to make some servos a little glitchy.
You gotta just play around with the numbers.
I’m going to report the car tutorial as broken, let’s see if they fix it or add it to their new documention.
The other issue is if you don’t align the hinge with the wheel centerline then the wheel spinning forward will try to turn around the steering hinge.
I’ve also used welded motors with rods connecting them to the steering, like a real car does. This balances out the forces, and the motor is way less springy than a HingeConstraint.
Try this place out: Tracked vehicle, suspension and racing tests. - Roblox