Class Steering
Vehicle steering system that handles front and rear wheel steering with support for Ackermann geometry, speed-sensitive steering, and visual steering wheel animation.
Inherited Members
Namespace: NWH.VehiclePhysics2
Assembly: NWH.VehiclePhysics2.dll
Syntax
[Serializable]
public class Steering : VehicleComponent
Remarks
The Steering component manages the conversion of steering input into wheel angles, applying proper Ackermann geometry for multi-wheel axles to ensure realistic turning behavior. It supports both front and rear steering configurations through wheel group steer coefficients.
Key features include: - Speed-sensitive steering reduction for stability at high speeds - Configurable steering rate limiting to simulate power steering response - Automatic Ackermann geometry calculation for proper tire slip angles - Visual steering wheel rotation synchronization - Support for both raw and processed steering input modes
The speed-sensitive curve reduces maximum steering angle at higher speeds to improve stability. At low speeds (0-30 km/h), full steering angle is available for maneuverability. At highway speeds (100+ km/h), steering is reduced to prevent oversteer.
Fields
angle
Current steering angle in degrees applied to the wheels.
Declaration
[ShowInTelemetry(NaN, NaN, null, null, 1)]
[Tooltip("Current steer angle.")]
public float angle
Field Value
| Type | Description |
|---|---|
| float |
Remarks
This is the actual angle after processing through speed-sensitive curves, rate limiting, and input smoothing. Positive values indicate right turn, negative values indicate left turn. Range is typically -maximumSteerAngle to +maximumSteerAngle.
assistCounterSteerReward
Reduces assist when player is already counter-steering correctly (0-1). Higher values reward skilled players by reducing intervention when they're already correcting.
Declaration
[Range(0, 1)]
[Tooltip("Reduces assist when player counter-steers correctly. 0 = no reduction, 1 = full reduction.")]
public float assistCounterSteerReward
Field Value
| Type | Description |
|---|---|
| float |
assistCounterSteerThreshold
Minimum steering angle in degrees before counter-steer is detected.
Declaration
[Range(1, 10)]
[Tooltip("Minimum steering angle (deg) to detect counter-steering.")]
public float assistCounterSteerThreshold
Field Value
| Type | Description |
|---|---|
| float |
assistDerivativeGain
Derivative gain for the steering assist PD controller. Higher values dampen oscillations but may reduce responsiveness.
Declaration
[Range(0, 1)]
[Tooltip("Derivative gain (kD). Dampens oscillations.")]
public float assistDerivativeGain
Field Value
| Type | Description |
|---|---|
| float |
assistDerivativeSmoothing
Smoothing time for the derivative term to reduce noise/jitter.
Declaration
[Range(0, 0.1)]
[Tooltip("Derivative smoothing time (seconds). Reduces noise/jitter.")]
public float assistDerivativeSmoothing
Field Value
| Type | Description |
|---|---|
| float |
assistMaxAngle
Maximum steering correction the assist can apply in degrees. Limits how much the assist can override player steering.
Declaration
[Tooltip("Maximum correction angle the assist can add (degrees).")]
public float assistMaxAngle
Field Value
| Type | Description |
|---|---|
| float |
assistMinSpeed
Minimum speed in m/s for assist to activate. Prevents intervention during low-speed maneuvers.
Declaration
[Tooltip("Minimum speed (m/s) for assist activation. Prevents intervention at low speeds.")]
public float assistMinSpeed
Field Value
| Type | Description |
|---|---|
| float |
assistOutputSmoothing
Smoothing time for the assist output angle.
Declaration
[Range(0, 0.2)]
[Tooltip("Output smoothing time (seconds). Prevents sudden corrections.")]
public float assistOutputSmoothing
Field Value
| Type | Description |
|---|---|
| float |
assistProportionalGain
Proportional gain for the steering assist PD controller. Higher values increase response to current slip angle.
Declaration
[Range(0.1, 2)]
[Tooltip("Proportional gain (kP). Controls response to current slip angle.")]
public float assistProportionalGain
Field Value
| Type | Description |
|---|---|
| float |
assistSlipThreshold
Vehicle slip angle threshold in degrees before assist activates. Lower values make assist more sensitive, higher values only assist larger slides.
Declaration
[Tooltip("Slip angle threshold before assist activates (degrees). Lower = more sensitive.")]
public float assistSlipThreshold
Field Value
| Type | Description |
|---|---|
| float |
assistSpeedCurve
Curve defining assist strength by speed. X = speed (0-50 m/s normalized to 0-1), Y = multiplier (0-1).
Declaration
[Tooltip("Assist strength by speed. X: 0-50 m/s normalized, Y: strength multiplier.")]
public AnimationCurve assistSpeedCurve
Field Value
| Type | Description |
|---|---|
| AnimationCurve |
counterSteerRateMultiplier
Multiplier for steering rate when counter-steering (steering opposite to vehicle slip). Higher values allow faster corrections during oversteer recovery.
Declaration
[Range(1, 5)]
[Tooltip("Steering speed multiplier when counter-steering. 2-4x recommended for keyboard.")]
public float counterSteerRateMultiplier
Field Value
| Type | Description |
|---|---|
| float |
counterSteerSlipThreshold
Vehicle slip angle threshold in degrees before counter-steer rate boost activates.
Declaration
[Tooltip("Slip angle threshold before counter-steer rate boost activates.")]
public float counterSteerSlipThreshold
Field Value
| Type | Description |
|---|---|
| float |
damage
Current damage level of the steering system (0-1). Affects max angle and causes offset.
Declaration
[NonSerialized]
[Tooltip("Current steering system damage (0-1).")]
public float damage
Field Value
| Type | Description |
|---|---|
| float |
damageAngleReduction
Maximum steering angle reduction at full damage (0-1). 0.3 = 30% angle reduction at damage=1.
Declaration
[Range(0, 0.5)]
[Tooltip("Maximum steering angle reduction at full damage (0-1). 0.3 = 30% reduction when damage=1.")]
public float damageAngleReduction
Field Value
| Type | Description |
|---|---|
| float |
damageSteeringOffset
Maximum steering offset (pull) in degrees at full damage. Vehicle will pull to one side.
Declaration
[Range(0, 15)]
[Tooltip("Maximum steering offset (pull) in degrees at full damage. Vehicle pulls to one side.")]
public float damageSteeringOffset
Field Value
| Type | Description |
|---|---|
| float |
degreesPerSecondLimit
Maximum steering rate in degrees per second when rate limiting is enabled. Controls how quickly the wheels can change their steering angle.
Declaration
[Tooltip("Only used if limitSteeringRate is true.Will limit wheels so that they can only steer up to the set degreelimit per second. E.g. 60 degrees per second will mean that the wheels that have 30 degree steer angle willtake 1 second to steer from full left to full right.")]
[ShowInSettings("deg/s Limit", 50, 500, 10)]
public float degreesPerSecondLimit
Field Value
| Type | Description |
|---|---|
| float |
Remarks
This simulates the response time of power steering systems and prevents unrealistic instant steering changes. Only applied when useRawInput is false (processed steering mode).
Low values (60-120 deg/s): Slow, realistic power steering response. Good for heavy vehicles. High values (300-500 deg/s): Fast, responsive steering. Good for sports cars and arcade gameplay.
Example: With 30° maximum steer angle and 180 deg/s limit, full lock-to-lock takes 0.33 seconds.
externallyAddedAngle
Additional steering angle added to the final steering calculation. Bypasses all input processing, smoothing, and rate limiting.
Declaration
[Tooltip(" angle added to the user set angle, used mostly for motorcycle balancing.\r\n To add angle to the current steer angle use this instead of angle, since this goes around smoothing and clamping.")]
public float externallyAddedAngle
Field Value
| Type | Description |
|---|---|
| float |
Remarks
This value is added directly to the processed steering angle before applying it to the wheels. It's primarily used for automated steering assistance like motorcycle balance control, lane-keep assist, or stability management systems.
Unlike modifying the main angle property, this bypasses all input processing and is applied immediately without smoothing or clamping. Use this for external steering inputs that need to override or supplement user input.
linearity
Curve defining the relationship between steering input (0-1) and steering angle response (0-1). Controls the non-linearity of steering input to provide more precise control around center.
Declaration
public AnimationCurve linearity
Field Value
| Type | Description |
|---|---|
| AnimationCurve |
Remarks
X-axis represents normalized steering input (0 = center, 1 = full input). Y-axis represents normalized steering angle output (0 = no steering, 1 = maximum angle).
Linear curve (default): Direct 1:1 relationship between input and steering angle. S-curve: More precise control around center, aggressive at extremes. Good for racing. Progressive curve: Less sensitive at center, more responsive at extremes. Good for casual driving.
maximumSteerAngle
Maximum steering angle in degrees that the wheels can achieve. Defines the vehicle's turning radius and maneuverability.
Declaration
[Range(0, 90)]
[ShowInSettings("Max. Steer Angle", 5, 50, 5)]
[Tooltip("Maximum steering angle at the wheels.")]
public float maximumSteerAngle
Field Value
| Type | Description |
|---|---|
| float |
Remarks
This is the absolute maximum angle the wheels can turn when steering input is at maximum. The actual achievable angle may be reduced by the speed-sensitive steering curve at higher speeds.
Low values (15-25°): Realistic for most road vehicles. Larger turning radius but stable at speed. Medium values (30-40°): Good for versatile vehicles. Balance between maneuverability and stability. High values (45°+): Very maneuverable, tight turning radius. May be unstable at high speeds.
Typical values: Compact car (30-35°), Sedan (25-30°), SUV/Truck (35-45°), Racing car (15-25°).
returnToCenter
Controls whether wheels automatically return to center position when no steering input is applied.
Declaration
[ShowInSettings("Return to Center")]
[Tooltip("Should wheels return to neutral position when there is no input?")]
public bool returnToCenter
Field Value
| Type | Description |
|---|---|
| bool |
Remarks
When enabled, wheels will gradually return to straight-ahead position when steering input becomes zero. When disabled, wheels maintain their current angle until new input is applied.
Enable for: Most vehicles, realistic driving behavior, automatic centering after turns. Disable for: Manual control requirements, specific gameplay mechanics, or when external systems control centering.
smoothTime
Time in seconds for steering to reach its target angle. Uses SmoothDamp for natural momentum-based steering feel.
Declaration
[Range(0.01, 0.3)]
[ShowInSettings("Smooth Time", 0.01, 0.3, 0.01)]
[Tooltip("Time in seconds for steering to reach target. Lower = faster response, higher = smoother/heavier feel.")]
public float smoothTime
Field Value
| Type | Description |
|---|---|
| float |
Remarks
Lower values result in faster, more responsive steering. Higher values create smoother, heavier-feeling steering suitable for trucks and heavy vehicles.
Typical values: Sports car (0.04-0.06s), Sedan (0.06-0.10s), Truck/SUV (0.10-0.15s).
smoothing
[Obsolete] Use smoothTime instead. Kept for backwards compatibility.
Declaration
[HideInInspector]
[Obsolete("Use smoothTime instead. This field is kept for backwards compatibility migration.")]
public float smoothing
Field Value
| Type | Description |
|---|---|
| float |
speedSensitiveSteeringCurve
Curve defining how maximum steering angle is reduced with vehicle speed for improved stability. X-axis represents normalized speed (0-1 = 0-50 m/s), Y-axis represents steering multiplier (0-1).
Declaration
[Tooltip("Curve that shows how the steering angle behaves at certain speed.\r\nX axis represents velocity in range 0 to 50m/s (normalized to 0,1).\r\nY axis represents 0 to maximumSteerAngle (normalized to 0,1).")]
public AnimationCurve speedSensitiveSteeringCurve
Field Value
| Type | Description |
|---|---|
| AnimationCurve |
Remarks
This curve multiplies the maximumSteerAngle based on current vehicle speed to provide realistic high-speed stability. At low speeds, full steering angle is available for maneuverability. At high speeds, steering is progressively reduced to prevent dangerous oversteer.
The default curve provides: - Full steering (1.0x) at 0 km/h for parking and low-speed maneuvering - Reduced steering (0.6x) at ~54 km/h (0.3 normalized) for city driving - Minimal steering (0.1x) at 180+ km/h (1.0 normalized) for highway stability
Adjust this curve based on vehicle type: Sports cars can have more aggressive reduction, while trucks might need gentler curves to maintain maneuverability.
speedSensitiveSteeringRateCurve
Curve defining how steering rate is reduced with vehicle speed. X-axis: normalized speed (0-1 = 0-50 m/s), Y-axis: rate multiplier (0-1).
Declaration
[Tooltip("Curve that reduces steering rate at higher speeds. X: speed (0-50m/s normalized), Y: rate multiplier (0-1).")]
public AnimationCurve speedSensitiveSteeringRateCurve
Field Value
| Type | Description |
|---|---|
| AnimationCurve |
Remarks
This curve multiplies the smoothing value based on vehicle speed. Lower values at high speed mean slower steering response, which helps keyboard players maintain control at highway speeds. Only affects steering input rate, not return-to-center behavior.
steeringAssistStrength
Strength of steering assist (0 = disabled, 1 = full assist). Automatically adds counter-steer when vehicle is sliding to help maintain control.
Declaration
[Range(0, 1)]
[ShowInSettings("Assist Strength", 0, 1, 0.1)]
[Tooltip("Steering assist strength. 0 = disabled, 1 = full assist. Helps counter-steer during slides.")]
public float steeringAssistStrength
Field Value
| Type | Description |
|---|---|
| float |
steeringWheel
Transform of the visual steering wheel object that will be rotated to match steering input. Leave null if no visual steering wheel rotation is needed.
Declaration
[Tooltip("Steering wheel transform that will be rotated when steering. Optional.")]
public Transform steeringWheel
Field Value
| Type | Description |
|---|---|
| Transform |
Remarks
When assigned, this transform will be automatically rotated around its Z-axis to visually represent the current steering angle. The rotation is calculated using the steeringWheelTurnRatio.
The steering wheel should be modeled in its default (straight) position, and this component will handle the rotation automatically during gameplay. Useful for first-person vehicle views and cockpit displays.
steeringWheelTurnRatio
Multiplier that converts steering wheel angle to visual steering wheel rotation. Controls how many degrees the visual steering wheel rotates relative to the actual wheel steering angle.
Declaration
[Tooltip("Steer angle will be multiplied by this value to get steering wheel angle. Ignored if steering wheel is null.\r\nIf you want the steering wheel to rotate in opposite direction use negative value.")]
public float steeringWheelTurnRatio
Field Value
| Type | Description |
|---|---|
| float |
Remarks
This ratio simulates the gear reduction between the steering wheel and the actual wheels. Real vehicles typically have ratios between 10:1 to 20:1, meaning the steering wheel must turn 10-20 degrees to move the wheels 1 degree.
Positive values: Normal rotation direction. Negative values: Reverse rotation direction (useful if the steering wheel model is oriented differently).
Typical values: Sports car (12-15), Sedan (16-18), Truck (20-24), Racing car (8-12).
useRawInput
Controls whether steering input is processed or applied directly to the wheels. When enabled, bypasses all smoothing, rate limiting, and speed-sensitive adjustments.
Declaration
[ShowInSettings("Raw Input")]
[Tooltip("If true direct steering input will be used, without any modification.")]
public bool useRawInput
Field Value
| Type | Description |
|---|---|
| bool |
Remarks
Raw Input (true): Direct input-to-wheel mapping. Instant response, no processing applied. Processed Input (false): Input goes through smoothing, speed sensitivity, linearity curves, and rate limiting.
Use Raw Input for: Arcade-style games, simple steering behavior, debugging, or when implementing custom processing. Use Processed Input for: Realistic vehicle behavior, racing simulations, or when using gamepad/keyboard input.
Methods
CalculateSteerAngles(float)
Calculates and applies steering angles to all wheel groups based on current input and vehicle state. Handles input processing, speed sensitivity, Ackermann geometry, and rate limiting.
Declaration
public virtual void CalculateSteerAngles(float DeltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | DeltaTime | Time elapsed since the last update, used for rate limiting calculations |
Remarks
Processes input through configured curves and applies angles to each wheel group. For 2-wheel groups, calculates Ackermann geometry for realistic turning.
CalculateWheelbase()
Calculates the wheelbase (distance between front and rear axles) for the current vehicle configuration.
Declaration
public float CalculateWheelbase()
Returns
| Type | Description |
|---|---|
| float | Wheelbase distance in meters, or -1 if the vehicle doesn't have a standard 2 or 4 wheel configuration |
Remarks
4-wheel: distance between wheels[0] and wheels[2] (FL to RL). 2-wheel: distance between wheels[0] and wheels[1]. Other configurations return -1. Used for Ackermann calculations.
VC_FixedUpdate(float)
Physics update called at fixed intervals. Override to implement physics-based behavior.
Declaration
public override void VC_FixedUpdate(float DeltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | DeltaTime | Time elapsed since last FixedUpdate in seconds |
Overrides
Remarks
Only called when the component is active (initialized and enabled). Use for physics calculations, force application, and other fixed-timestep operations. Called from VehicleController.FixedUpdate().
VC_Initialize()
Initializes the component's internal systems and resources. Called once during vehicle startup after the VehicleController reference is set.
Declaration
protected override void VC_Initialize()
Overrides
Remarks
Override this to set up component-specific resources, cache references, or perform one-time initialization. Sets state.initialized to true on completion.
VC_SetDefaults()
Resets the component to default configuration. Override to provide component-specific default values.
Declaration
public override void VC_SetDefaults()
Overrides
Remarks
Called when the vehicle is reset or when first added to a GameObject. Should set all serialized fields to sensible default values. May load default assets from Resources folder.
VC_Validate(VehicleController)
Validates the component configuration and reports any setup issues. Override to implement component-specific validation rules.
Declaration
public override void VC_Validate(VehicleController vc)
Parameters
| Type | Name | Description |
|---|---|---|
| VehicleController | vc | Parent VehicleController to validate against |
Overrides
Remarks
Called in Editor when validation is triggered manually or automatically. Should use Debug.LogWarning/Error to report configuration problems. Check for null references, invalid values, missing dependencies, etc.
VisualUpdate()
Updates the visual steering wheel rotation to match the current steering angle. Called each frame to keep visual elements synchronized with the steering state.
Declaration
public virtual void VisualUpdate()
Remarks
Rotates the steering wheel Transform around Z-axis by angle * steeringWheelTurnRatio. No-op if no steering wheel is assigned.