Some new juicy math with illustration. This is a “half” of the suspension force equation which talks only about calculating Spring part of the force:
This should simplify tweaking of the suspension. The idea is following:
- let’s say you know where suspension is connected to chassis and wheel (or guesstimate). Distance between those connection points is Rst, assuming that vehicle is in a reference pose - just standing still with suspension already engaged under the specified weight.
- Min will be a minimal distance to which your suspension can be compressed. Again you could find it somewhere in specification or just decided that this is the limit to which you will compress or animate suspension mesh.
- Max is the distance at which spring is completely uncompressed and there is no spring force generated. If suspension is stretched beyond this value then spring should work the other way - start to pull objects instead of push.
-
Curr is what we get from calculating position of the wheel or what ever else is connected to the spring
Note: Max and Curr are calculated automatically in algorithm and don’t need to be tweaked - After you’ve setup Rst and Min just start changing Stiffness of the spring until vehicle balances just as on reference drawings or achieves necessary clearance
Second part of equation is “dampener” or “shock absorber”. It’s not show in diagram as it’s the same as it was before:
Dampener Force = Damping Coefficient * Suspension Target Velocity * Current Suspension Velocity
where suspension velocity is the velocity of it’s compression. The only new change I’ve added is scaling of the dampening force by 25% or 75% percent depending if suspension is compressing or expanding. We want suspension to react quickly to compression when wheel/track/ski hits surface so Damping Force is only at 0.25 at the same time when suspension expands we don’t want to do it too fast so Damping Force at this point is 0.75
Actual code looks like this: