Ammo.js Vehicle Suspension Tuning Guide
Configuring realistic vehicle physics in a 3D browser application
requires a precise setup of the wheel suspension system. In
ammo.js (the JavaScript port of the Bullet physics engine),
the btRaycastVehicle class relies on several key suspension
parameters to simulate weight distribution, shock absorption, and road
handling. This article covers the essential suspension parameters you
need to tune to achieve stable, realistic, or arcade-style vehicle
dynamics in your simulation.
1. Suspension
Stiffness (suspensionStiffness)
This parameter defines the rigidity of the suspension spring. It determines how much the spring resists compression under the vehicle’s weight. * Low values (10.0 - 20.0): Ideal for off-road vehicles, trucks, or heavy machinery where a soft, bouncy suspension with large travel is desired. * High values (30.0 - 50.0+): Ideal for sports cars or racing vehicles. It keeps the chassis flat during cornering but makes the ride much stiffer.
2.
Suspension Connection Length / Rest Length
(suspensionRestLength)
This defines the length of the suspension spring when it is fully extended and under no load. * It acts as the primary tool for setting the vehicle’s ride height. * Ensure your raycast wheels have enough distance to travel down to the ground from the chassis connection point without clipping through the vehicle body.
3. Damping
Compression (wheelsDampingCompression)
Compression damping controls the resistance force when the wheel
moves upward (compressing the suspension spring) due to bumps or landing
from jumps. * Low values: The suspension compresses
easily, which can cause the vehicle to “bottom out” (the chassis hitting
the ground). * High values: The suspension resists
quick upward movement, making the vehicle feel heavier and more stable
over small bumps, though excessively high values can make the vehicle
react violently to obstacles. * Typical Range: Often
set between 0.1 * stiffness and
0.3 * stiffness.
4. Damping
Relaxation / Rebound (wheelsDampingRelaxation)
Relaxation damping (also known as rebound damping) controls the
resistance when the suspension spring extends back to its original
length after being compressed. * This is the most critical parameter for
preventing your vehicle from bouncing endlessly like a toy. *
Rule of Thumb: This value must always be higher than
the compression damping. If your vehicle bounces uncontrollably after
hitting a bump, increase this value. * Typical Range:
Often set between 0.2 * stiffness and
0.5 * stiffness.
5. Maximum
Suspension Travel (maxSuspensionTravelCm)
Measured in centimeters, this parameter defines the maximum distance the wheel is allowed to travel along its suspension axis. * It prevents the wheel from retracting too far into the vehicle chassis. * For sports cars, keep this value low (e.g., 10 to 20 cm). For off-road vehicles, increase it significantly (e.g., 50 to 100 cm) to allow the wheels to hug uneven terrain.
6. Maximum
Suspension Force (maxSuspensionForce)
This represents the maximum force that the suspension spring can exert upward against the vehicle chassis. * If this value is too low, the suspension will collapse under the weight of the vehicle, causing the chassis to drag on the floor. * For stable simulation, especially with heavy chassis masses, set this value high (e.g., 3000.0 to 10000.0+) to ensure the springs can always support the vehicle’s mass under gravity.