Class Spring
Suspension spring with configurable force and compression characteristics. Force = MaxForce * Compression^Progressiveness. Set progressiveness to 1.0 for linear springs,
1.0 for progressive (stiffer when compressed), <1.0 for digressive (softer when compressed). MaxForce should support ~3x static wheel load with spring resting at ~30% compression.
Namespace: NWH.WheelController3D
Assembly: NWH.WheelController.dll
Syntax
[Serializable]
public class Spring
Fields
| Edit this page View Sourcecompression
Compression from 0 (extended) to 1 (bottomed out). Should rest around 0.3 under static load. Values near 1.0 indicate suspension is bottoming out.
Declaration
[NonSerialized]
[ShowInTelemetry(0, 1, "0.00", null, 1)]
[Tooltip("Spring compression from 0 (extended) to 1 (bottomed out). Should rest around 0.3.")]
public float compression
Field Value
| Type | Description |
|---|---|
| float |
compressionVelocity
Compression rate in m/s. Positive = compressing, negative = extending. Used by damper for velocity-dependent forces.
Declaration
[NonSerialized]
[ShowInTelemetry(NaN, NaN, null, null, 1)]
[Tooltip("Spring compression speed in m/s. Positive = compressing, Negative = extending.")]
public float compressionVelocity
Field Value
| Type | Description |
|---|---|
| float |
extension
Extension from 0 (compressed) to 1 (extended). Inverse of compression.
Declaration
[NonSerialized]
[Tooltip("Spring extension from 0 (compressed) to 1 (extended). Inverse of compression.")]
public float extension
Field Value
| Type | Description |
|---|---|
| float |
forceMagnitude
Current spring force in Newtons. At rest, should equal ~(mass * gravity / wheelCount).
Declaration
[NonSerialized]
[Tooltip("Current spring force in Newtons. Pushes wheel away from vehicle body.")]
public float forceMagnitude
Field Value
| Type | Description |
|---|---|
| float |
length
Current spring length in meters, between 0 and maxLength.
Declaration
[NonSerialized]
[ShowInTelemetry(NaN, NaN, null, null, 1)]
[Tooltip("Current spring length in meters. Determines wheel vertical position.")]
public float length
Field Value
| Type | Description |
|---|---|
| float |
maxForce
Maximum force at full compression (N). Start with (mass * g * 3) / wheelCount. 8000-20000N for cars, 20000-50000N for trucks. Adjust until spring rests at ~30% compression.
Declaration
[Tooltip("Maximum spring force in Newtons when fully compressed. Higher = stiffer suspension.")]
public float maxForce
Field Value
| Type | Description |
|---|---|
| float |
maxLength
Maximum spring length (m). Sports cars: 0.05-0.15m. Passenger cars: 0.15-0.25m. SUVs: 0.25-0.40m. Off-road: 0.30-0.60m. Longer = better bump absorption but more body roll.
Declaration
[Tooltip("Maximum spring length in meters. Defines total suspension travel available.")]
public float maxLength
Field Value
| Type | Description |
|---|---|
| float |
prevLength
Previous frame's spring length - used internally to calculate compression velocity.
Declaration
[NonSerialized]
[Tooltip("Previous frame's spring length. Used to calculate compression velocity.")]
public float prevLength
Field Value
| Type | Description |
|---|---|
| float |
progressiveness
Spring curve shape. 1.0 = linear. Below 1.0 = digressive (comfort). Above 1.0 = progressive (sport). 0.5-0.8: luxury, 1.0: road cars, 1.2-1.5: sports cars, 1.5-2.0: racing.
Declaration
[Range(0.5, 2)]
[Tooltip("Spring curve shape. 1.0=linear, <1.0=comfort (digressive), >1.0=sport (progressive).")]
public float progressiveness
Field Value
| Type | Description |
|---|---|
| float |