(Un)realistic Car Suspension

Using some of the code from this thread, I managed to put together some cool car suspension. :DDD

1 Like

The car never dropped from the sky to where I could use it.

EDIT: but also, looks quite a bit like Blockland.

EDIT 2: you should have the instructions in the thread too.

Make a game with these. :stuck_out_tongue:

Cartoon cars! idk

[quote] The car never dropped from the sky to where I could use it.

EDIT: but also, looks quite a bit like Blockland. [/quote]

read description pls

Love how the cars look and how they feel! I liked the suspension :smiley: Also he particles were cool! Make something out of this!

a little wonky but better than anything i can make right now!

no idea how to script a spring

How’d you dig up my old thread? xD

If you flip the car it urgently attempts to flip back up, resulting in some funny somersaults lol

[quote] a little wonky but better than anything i can make right now!

no idea how to script a spring [/quote]

it’s actually incredibly simple:
Force = -constant * linear deformation

the Force you can apply directly to a BodyThrust without any alteration. The only thing you have to do is tune the constant so that the spring is stiff enough for use.

Now, if you get oscillations from this simple system, you will want a damper. A damper applies force not based on distance, but on the first derivative of position, velocity. A damper is simply modeled as: Force = -constant * velocity. When you calculate velocity, it’s crucial to transform it into local coordinates, the easiest way being part.CFrame:vectorToObjectSpace(part.Velocity). Combining the two equations together gets you:
Force = -constantlinear-constantvelocity, or, in roblox terms, something along the line of:

BodyThrust.force = -10*(part1.Position-part2.Position).magnitude-10*part1.CFrame:vectorToObjectSpace(part1.Velocity-part2.Velocity)

assuming that part1 is the spring and part2 is a brick that represents the center position of the spring.

BUT ALSO, if you do something like a spring and damper model, then congratulations! You’ve created your first PID system, just without an I term. Be aware though, that by the nature of the system, the spring will not find equilibrium at the center point: when the distance is 0, 0 force is applied: there must be at least a little distance for the constant to catch up with the force being applied.

1 Like

You could make the funnest racing game ever with this.