How to properly tune spring constraints for cars. (Critical damping formula)

Idk if this is in the right category.

Hello. At some point in roblox development, you have probably tried making a vehicle chassis. And if you have spent any reasonable time tuning your cars, you might notice how hard it is to tune the car suspension, or how long you can spend tweaking values, play testing, tweaking values, and playtesting. Or you might be a perfectionist like me. Where you tune your car really well, and then you either notice something really tiny, and minor that no one else will notice, or you might be wondering if you can tune your car even better, or go even farther, or you might not know if your car is even tuned correctly.

Well… in this topic, I will have (hopefully) saved you from countless hours of playtesting, tweaking, and not being satisfied with how well your car is tuned.

If you have ever made a car system, you might notice how ‘stiff’ your suspension is, or how it might feel like your car doesn’t even have suspension at all even though your car has spring constraints.

Here is a video of what I mean:

Ok, that video might have been a bad example, but I think you probably get the point. You have spring constraints, but they aren’t very soft, they are very ‘tough’, and it almost feels like there are no springs at all.

Here is a video of what the car suspension should feel like:

Maybe the springs on that car still seem a little ‘stiff’, but they are noticeably softer than the video with the other springs.

So. If you’ve ever made a car chassis, you’ve probably just set your spring stiffness, and damping to something random like 10k, and 500, and just left it as is. And that is probably why your car’s suspension feels ‘tough’, and not soft.

We will be taking a look at the critical damping formula/equation to figure out the right damping values for our springs (2 * math.sqrt(mass * stiffness) * TuningConstant) / Wheel_Count, but I couldn’t find any good formula to tune the stiffness, so I will just be using (mass * gravity) / Desired_Suspension_Height / Wheel_Count to figure out the ideal stiffness. I randomly came up with this, and it works really well for me and so that is why I will be using it.
(I know that Wikipedia exists, but it is way too hard to understand)

How to figure out the car's mass, and gravity.

If your car is like mine, and the mass depends on the mass of just one block, all you really need to do is select the part, and go to properties, and then find the mass property. If you can’t find this property, then reference the part in a line of code, and then call :GetMass() and then print it. In my case print(workspace.DefaultDuneBuggy.Chassis.Mass:GetMass(). And then run it in the command line/command bar. And it will print the mass of the car in the output.

If all of the parts of your car have mass, you need to loop through each BasePart (Meshes, Unions, Parts, Wedges, etc…) in the car, and add all of their masses together.

local mass = 0
for index, instance in pairs(Car_Reference:GetDescendants()) do
    if instance:IsA("BasePart") then
        mass = mass + instance:GetMass()
   end
end
print(mass)

Run this in the command bar (make sure to replace Car_Refrence with the reference to your car), and then it will print the total mass of your vehicle.

To figure out gravity, then just go to workspace, and then find the gravity property. If you can’t find this property, then just run print(workspace.Gravity) in the command line, and it will print the gravity in the game into the output.

Ok. Now.
My car’s mass is 3200, the gravity in the game is 196.2, and the amount of wheels my car has is 4.

Now to figure out the stiffness, we can first multiply the mass (3200) by the gravity (196.2). We get the number (627840). Next, we divide this by the desired suspension height. The desired suspension height is the desired distance from the center of the wheel that you want your car to be at on a perfectly flat surface. So, on my car, I want each corner of my chassis to be at least 3 studs away from the center of the wheel associated with that corner. (So the Back Left corner of the car should be at least 3 studs higher than the center of the back left tire/wheel, etc…)

So We divide this number (627840) by 3. This gives us 209280. Next, I have 4 wheels on my car, so I should divide this number (209280) by 4, this gives us 52320. This is roughly what the ideal stiffness of our springs should be.

Next, we need to figure out the ideal damping for our car.

First, we take our car’s mass which is (3200), and then we multiply it by the stiffness of our springs which is (52320). This gives us quite a large number (167424000). Now we need to get the square root of this number (167424000), which gives us (12939.2426363). Next we need to multiply this number (12939.2426363) by 2. This now gives us (25878.4852726).

We now have to deal with something called the damping, or tuning constant. Basically what this number does is it determines how much our car should bounce when we hit a bump, or when we are on really rough / bumpy terrain. If you really don’t care about this number, or want the car to ‘be little bouncy as possible’, just go ahead and set it to 1. But if you care about this number or something, then here is a tiny guide to the range of numbers you should set it too. For every day vehicles (Like sedans or regular civilian vehicles that you drive from home to work, and back almost every day), set this number to anywhere from 0.3 to 0.6, for off roaders where you don’t care about stability at high speeds, you just want to have fun in the mountains or something like that, you could set it to anywhere from .3 to 0.6. For sports cars where you want to have as much stability as possible at high speeds, and you don’t want to go flying off the track or road or loosing control if you hit a bump, you want to set this to anywhere from 0.6 to 0.9.

Ok. Now. I’m going to set this number to 0.75 for my car, but you can set this to whatever you want. If we multiply our number (25878.4852726) by our tuning/damping constant 0.75 we will get the number 19408.8639545. All we have left to do is divide our number (19408.8639545) by the amount of wheels on our car. In my case my car has 4 wheels, so I will divide this number (19408.8639545) by 4. We now have 4852.21598863.

And there you go! You now (hopefully) have the ideal stiffness and damping for your vehicle.

If you are having any more issues, try making the stiffness not divide by 4. So just (mass * gravity), and then re-configure the spring damping.

Also, try setting your wheels to massless (If this gives you any issues, feel free to revert them back to not massless).

If your car is also too bouncy, feel free to re-configure the damping, and then set the ‘magic’ constant to 1, and reconfigure the damping.

Also, when I refer to the ‘stability of a vehicle’, I’m referring to how much control you have of the vehicle at high speeds. If a car has really good stability, then you will have very little under steer, very little over steer, your car wont bounce excessively or go flying after hitting a bump at like 150+ miles per hour, and you won’t loose control and spin out from hitting a bump at that speed.

I was also a bit tired while editing my post, so if you find something weird, or I didn’t say something correctly, please feel free to correct me, or tell me so I can fix it.

Anyway. If you have any suggestions on how I could improve this, or want to contribute to this topic, please feel free to let me know, or reply.

42 Likes

When i try this, my wheels just disappear.

1 Like

In order for this tutorial to work well, your wheels need to have mass. My car works perfectly fine. I had an issue with my chassis where the wheels would act all wonky, and would be oscillating at extremely high rates of speed even when the rest of the car was not under any stress or when the rest of the car was stationary. And sometimes the wheels would glitch through the ground. The way I fixed this issue was by giving them more density.

Car thingy xD.rbxm (14.9 KB)

This is my car file, it is based on this car chassis, and it works great (bear in mind it does have some extra things inside of it that allow the scripts in my game to work properly, and some extra rubbish I forgot to clean up that my main game probably doesn’t even need anymore).

If your car’s wheels already have mass, then you might need to make them have more weight.

You can go to the car’s custom physical properties, and increase the density of the wheels to give them more weight.

What might be happening is the wheels on your car’s chassis are going through the ground, and so you can’t see them, and so you probably think they are invisible, when they actually aren’t invisible, they are just under the ground.

You could also be having an issue with network ownership (my car chassis had some issues, until I set the network ownership to the proper player, and set the player to be massless.)

8 Likes

This works pretty well for me so far, but I am not including wheels in the mass value. Is this something I should be doing? Or are wheel masses not meant to be included in the calculation.

1 Like

The wheel’s mass shouldn’t be included in the calculation because the wheel isn’t being lifted up by the spring constraints. Only the chassis. The wheels are being pushed downward (into the ground) due to the weight of the chassis on top of the spring constraints.

2 Likes

I’m setting this up myself, and I’ve found a few errors in the post. I will specify them below.

These are the same numbers.

Typo “Refrence”

Syntax error.

This will do nothing as wheels are not part of the assembly, which makes them automatically have mass. It is stated in the documentation.

“re(-)configure the damping” is stated twice.


For whatever reason, my stiffness settings were quite low. Removing the wheel count division from the math for the stiffness fixed it, but now I’m wondering if it was the same for damping. Apparrently, it was, and after testing I saw how less bouncy the cars were.

I’m unsure if this applies to all cars or not, as I’ve experienced serious problems when dividing the stiffness using the wheel count, almost as if it was not meant to be this way. I do know that a raycast car needs a mandatory wheel count divider for the damping, but maybe not in Roblox’s SpringConstraint system.

It should also be noted that increasing the density of the wheel also makes it more likely for the car to bounce when hitting a bump. I recommend a density of about 5-10 for light cars (mass under 5000), a density of 20 for medium cars (mass under 10000), and a density of 50-100 for cars that exceed that. I test these with wheels that have a radius of 1.5 (and are the Ball PartType). Adjusting the density also makes it increasingly difficult to tune the friction of the wheel.

FYI: You can also get the total mass through any part of the assembly using BasePart.AssemblyMass if the assembly is unanchored.

Edit: For my cars, the wheel count should be divided by 4 for some reason. Vehicles with more than four wheels appear to have really stiff suspension.

this tutorial is amazing and made my suspension 100% more realistic, although I had to leave out dividing the wheels and then it behaved good. I would have never found out this excellent way to tune springs correctly for cars that weigh realistically.

1 Like