I’m trying to make a car but I’m confused because I don’t know how the MaxSpeed Variable in the code below works. I don’t know why it needs to be divided by the radius of the wheel and the logic behind that.
Car script in car model
local car = script.Parent
local backLeft = car.BackLeft
local backRight = car.BackRight
local frontRight = car.FrontRight
local frontLeft = car.FrontLeft
local seat = car.VehicleSeat
local steerAngle = 30
local maxSpeed = seat.MaxSpeed / (frontLeft.Wheel.Size.Y/2)
seat:GetPropertyChangedSignal("SteerFloat"):Connect(function()
frontLeft.PartB.SteeringConstraint.TargetAngle = steerAngle * seat.SteerFloat
frontRight.PartB.SteeringConstraint.TargetAngle = steerAngle * seat.SteerFloat
end)
seat:GetPropertyChangedSignal("ThrottleFloat"):Connect(function()
frontLeft.Wheel.MotorConstraint.AngularVelocity = maxSpeed * seat.ThrottleFloat
frontRight.Wheel.MotorConstraint.AngularVelocity = maxSpeed * -seat.ThrottleFloat
backLeft.Wheel.MotorConstraint.AngularVelocity = maxSpeed * seat.ThrottleFloat
backRight.Wheel.MotorConstraint.AngularVelocity = maxSpeed * -seat.ThrottleFloat
end)