I am just trying to make a simple car that can turn accelerate and brake. I have however been stuck on an issue for a long while and cannot seem to fix this whenever I come across it when I try and make a car. Whenever I do make a car and test drive it, the front two wheels will jitter when the car accelerates and it disrupts the grip of the wheels and disrupts how the car handles at high speed. The wheels feel indecisive and very light to turn as they bounce as they hit the limit of their steering radius, what I am trying to get are wheels that stay in position and snap to one side and back to the middle when steering is 0
I’ve looked through devforum and cant find any articles that solve my problem, ive tried messing with the settings of constraints and everything but to be completely honest I have no idea what I am doing because it feels like whatever I do the properties aren’t making any positive difference.
Here’s the script
local bLeft = script.Parent.BackLeft
local bRight = script.Parent.BackRight
local fLeft = script.Parent.FrontLeft
local fRight = script.Parent.FrontRight
local seat = script.Parent.VehicleSeat
local speed = 50
local steerAngle = 10
seat:GetPropertyChangedSignal('Steer'):Connect(function()
fLeft.PartB.SteeringConstraint.TargetAngle = steerAngle*seat.Steer
fRight.PartB.SteeringConstraint.TargetAngle = steerAngle*seat.Steer
end)
seat:GetPropertyChangedSignal('Throttle'):Connect(function()
fLeft.Wheel.WheelConstraint.AngularVelocity = speed*seat.Throttle
fRight.Wheel.WheelConstraint.AngularVelocity = -speed*seat.Throttle
bLeft.Wheel.WheelConstraint.AngularVelocity = speed*seat.Throttle
bRight.Wheel.WheelConstraint.AngularVelocity = -speed*seat.Throttle
end)
Your script is enough for this task, the issue is with your constraints.
You can share a screenshot of them with having the “constraint details” enabled, make sure that they are centered with your wheels and they don’t prevent each other from moving before anything.
These are the properties of the steering constraints used on the two front wheels, the constraints are placed correctly from what I know, is there anything that I could change here?
Sorry, just realised what you meant by constraint details. The two on the inside are the steering constraints and the ones on the outside provide torque to the wheels for propulsion
for anyone wondering if i fixed it, i did and it works 100% of the time (will change this statement if i see anyone having problems with it)
instead of inputting the desired target angle, i changed the angular velocity of the steering constraint to have both wheels either turn left or right, and when they reach their desired angle their lower and upper limits would stop them (you would have to play around with this depending on how much you would like the car to steer)
here’s the basic code I used: (wheelbase is the steering wheel aesthetically inside the car) seat:GetPropertyChangedSignal('Steer'):Connect(function() fLeft.PartB.SteeringConstraint.LowerAngle = -15 fLeft.PartB.SteeringConstraint.UpperAngle = 15 fRight.PartB.SteeringConstraint.LowerAngle = -15 fRight.PartB.SteeringConstraint.UpperAngle = 15 script.Parent.WheelBase.HingeConstraint.LowerAngle = -70 script.Parent.WheelBase.HingeConstraint.UpperAngle = 70 fLeft.PartB.SteeringConstraint.AngularVelocity = steerSpeed*seat.Steer fRight.PartB.SteeringConstraint.AngularVelocity = steerSpeed*seat.Steer script.Parent.WheelBase.HingeConstraint.AngularVelocity = -5*seat.Steer if seat.Steer == 0 then fLeft.PartB.SteeringConstraint.LowerAngle = 0 fLeft.PartB.SteeringConstraint.UpperAngle = 0 fRight.PartB.SteeringConstraint.LowerAngle = 0 fRight.PartB.SteeringConstraint.UpperAngle = 0 script.Parent.WheelBase.HingeConstraint.LowerAngle = 0 script.Parent.WheelBase.HingeConstraint.UpperAngle = 0 end end)
probably not the most optimized code ever but it does work lmk if there are any issues in the comments of the video i posted because i believe the replies will slowly time out on this post