How can I make a car's deceleration slower?

I have a car with four wheels and with a currentVelocity property. Currently, when the player sets seat.Throttle to 0, the currentVelocity immediately drops to zero, causing the car to come to a complete stop within 5 seconds if it was previously traveling at 100 mph. I want to extend this deceleration period to 30 seconds, while also taking into account the surrounding environment. For example, if the car collides with an obstacle, the currentVelocity should be set to zero, and if the car is driving on a bumpy surface, it should be more challenging to maintain its speed.

I tried various options: getting rid of mass (which made the player insensitive to the car and didn’t change the situation), changing the MotorMaxTorque of HingeConstraints of the wheels (didn’t help either).

So, here’s the code I have so far:

if seat.Throttle == 0 then
  currentVelocity = 0
end
m1.AngularVelocity = -currentVelocity
m2.AngularVelocity = -currentVelocity
m3.AngularVelocity = -currentVelocity
m4.AngularVelocity = -currentVelocity

Why use AngularVelocity? HingeConstraints set to Motor are designed to do this.
You can change the MotorMaxTorque, AngularVelocity, and MotorMaxAcceleration Properties of the HingeConstraint.
If a car with HingeConstraint wheels hits something anchored, it stops immediately. You can tune the MotorMaxAccleration to accelerate and decelerate the car more realistically.

Yes, I’m setting up angularVelocity at HingeConstraints. I experimented with it, but it didn’t work out.

1 Like

How didn’t HingeConstraints work?
I’ve made plenty of cars with them.

They take a bit of tuning with wheel Density, Friction, and a few other things, but they work great.

Could you please provide some sample settings of this so that I can understand it?

It all depends on the weight of the car, the size of the wheels, how fast you want it to drive, etc.
Here’s a sample car I made for someone to show them how it can work.
Motor steering suspension car.rbxm (15.9 KB)

Read the script inside the Chassis Part. It explains a lot of how to set cars up and tune their handling.

Experiment with the values I have for the wheel HingeConstraints, the SpringConstraints, the Chassis Density, the wheel Densities and the wheel Friction Properties. Try big differences in the values to exaggerate the effect it has on the way the car drives and give you a better idea of what properties to mess around with for different effects.
Also remember that tuning a Roblox car’s handling and suspension is very much like a real car. If you make an adjustment to one thing it’ll affect all the others so don’t nitpick about just one Property. Get it roughly handling the way you want first by going through all these Properties, then do the fine tuning at the end.

I have a pre-built model with a suspension system and a well-designed body. However, despite my efforts to modify the wheel characteristics, the car consistently experiences excessive braking. To address this issue, I propose implementing a solution similar to the one used in A-Chassis, where a script gradually reduces the angular velocity after the player releases the gas pedal while considering the base speed. The root of the problem is how to take into account the actual speed when calculating currentVelocity.

Did you decrease the HingeConstraint MotorMaxAcceleration to try reducing the deceleration? That’s the best Property for this.
A couple alternatives:
If the car needs a high value of MotorMaxAcceleration to accelerate quickly then you could Script when the Throttle input is 0 or -1 to reduce the MotorMaxAcceleration during coasting and return it to the previous value when accelerating.
You can also script the MotorMaxTorque to decrease the same way to prevent rapid deceleration.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.