I have a script that is moving my cart. But it almost instantly reaches max speed. And I’m unsure how I can make it so it gradually increases / decreases in speed.
The script exists within the Vehicle Seat.
local leftWheel = script.Parent.Parent.LeftWheel
local leftWheel2 = script.Parent.Parent.LeftWheel2
local rightWheel = script.Parent.Parent.RightWheel
local rightWheel2 = script.Parent.Parent.RightWheel2
local speed = 45
script.Parent.Changed:Connect(function(property)
if property == "Throttle" then
leftWheel.AngularVelocity = speed * script.Parent.Throttle
leftWheel2.AngularVelocity = speed * script.Parent.Throttle
rightWheel.AngularVelocity = -speed * script.Parent.Throttle
rightWheel2.AngularVelocity = -speed * script.Parent.Throttle
end
end)
Any advice would be greatly appreciate as I’ve never messed with vehicles prior to this.
You can probably set the angular velocity back to 0,0,0 after accelerating as there is nothing stopping the cart from accelerating so quickly. Of course this may not work, but it’s worth a try
I’m guessing you’re using HingeConstraints and LeftWheel etc. are the name of the HingeConstraints turning your wheels.
Well speed = 45 is a bit quick.
That’s 45 radians per second which equals 2578.31 degrees per second!
speed = 6 would almost equal 360 degrees per second. Try that and tune it from there.
What is your MotorMaxTorque set to? I’m guessing your cart is pretty small so try a smaller number like 5000 and if the wheels have trouble rotating then increase it in steps of 5000 until your cart moves properly and can climb hills and keep the cart from stopping when it hits a small item.
What is your MotorMaxAcceleration set to? If it’s inf then the acceleration happens instantly. Try something like 10.
The size of your wheels also is a factor. Larger diameter wheels will make a vehicle travel faster.