Struct VehicleInputStates
One frame of vehicle input as processed by VehicleInputHandler. Analog axes are normalized to [0, 1] or [-1, 1], digital inputs are bool flags, and each analog axis also keeps its pre-smoothing raw value. Copyable between vehicles, e.g. truck to trailer, and writable directly by AI and replay code.
Namespace: NWH.VehiclePhysics2.Input
Assembly: NWH.VehiclePhysics2.dll
Syntax
[Serializable]
public struct VehicleInputStates
Remarks
With swapInputInReverse enabled on VehicleInputHandler, inputSwappedThrottle and inputSwappedBrakes carry the throttle and brake axes swapped while in reverse. In forward gears they match throttle and brakes.
Fields
NO_SHIFT
Value of shiftInto meaning "no gear requested". Sits outside the valid gear range, so it must never be range-clamped.
Declaration
public const int NO_SHIFT = -999
Field Value
| Type | Description |
|---|---|
| int |
NO_SHIFT_THRESHOLD
Anything above this is a live gear request; anything at or below it is the no-shift sentinel.
Declaration
public const int NO_SHIFT_THRESHOLD = -100
Field Value
| Type | Description |
|---|---|
| int |
boost
Boost activation state. True while the boost button is held down. Only functional when NOSModule or similar boost module is present and enabled.
Declaration
[NonSerialized]
[Tooltip("Boost flag. Only active if there is a boost module present.")]
public bool boost
Field Value
| Type | Description |
|---|---|
| bool |
brakes
Brake input normalized to [0, 1] range, where 0 is no braking and 1 is full braking force. This value may be modified by input smoothing or modification callbacks.
Declaration
[Range(0, 1)]
[NonSerialized]
[ShowInTelemetry(0, 1, "0.00", null, 1)]
[Tooltip("Brake input. The range is 0 to 1.")]
public float brakes
Field Value
| Type | Description |
|---|---|
| float |
brakesRaw
Raw brake input directly from the input provider without any modifications or smoothing.
Declaration
[HideInInspector]
[Tooltip("Same as brakes but without any modifications. Raw user input.")]
public float brakesRaw
Field Value
| Type | Description |
|---|---|
| float |
clutch
Clutch input normalized to [0, 1] range, where 0 is clutch fully engaged and 1 is clutch fully disengaged. Used with manual transmission for gear changes and preventing engine stalls.
Declaration
[Range(0, 1)]
[NonSerialized]
[ShowInTelemetry(0, 1, "0.00", null, 1)]
[Tooltip("Clutch input. The range is 0 to 1.")]
public float clutch
Field Value
| Type | Description |
|---|---|
| float |
clutchRaw
Raw clutch input directly from the input provider without any modifications or smoothing.
Declaration
[HideInInspector]
[Tooltip("Same as clutch but without any modifications. Raw user input.")]
public float clutchRaw
Field Value
| Type | Description |
|---|---|
| float |
cruiseControl
Toggle flag for cruise control. True when the button is pressed this frame. Only functional when CruiseControlModule is present and enabled.
Declaration
[NonSerialized]
[Tooltip("Cruise control flag. Only active if there is a cruise control module present.")]
public bool cruiseControl
Field Value
| Type | Description |
|---|---|
| bool |
engineStartStop
Toggle flag for starting or stopping the engine. True when the button is pressed this frame.
Declaration
[NonSerialized]
[Tooltip("Engine start/stop flag.")]
public bool engineStartStop
Field Value
| Type | Description |
|---|---|
| bool |
extraLights
Toggle flag for extra lights (fog lights, work lights, etc.). True when the button is pressed this frame.
Declaration
[NonSerialized]
[Tooltip("Extra lights flag.")]
public bool extraLights
Field Value
| Type | Description |
|---|---|
| bool |
flipOver
Flip-over request flag. True when the button is pressed this frame. Only functional when FlipOverModule is present and enabled, used to right overturned vehicles.
Declaration
[NonSerialized]
[Tooltip("Flip-over flag. Only active if there is a flip over module present.")]
public bool flipOver
Field Value
| Type | Description |
|---|---|
| bool |
handbrake
Handbrake input normalized to [0, 1] range, where 0 is released and 1 is fully engaged. Typically locks rear wheels for drifting or parking on slopes.
Declaration
[Range(0, 1)]
[NonSerialized]
[ShowInTelemetry(0, 1, "0.00", null, 1)]
[Tooltip("Handbrake input. Range is 0 to 1.")]
public float handbrake
Field Value
| Type | Description |
|---|---|
| float |
handbrakeRaw
Raw handbrake input directly from the input provider without any modifications or smoothing.
Declaration
[HideInInspector]
[Tooltip("Same as handbrake but without any modifications. Raw user input.")]
public float handbrakeRaw
Field Value
| Type | Description |
|---|---|
| float |
hazardLights
Toggle flag for hazard lights (all turn signals flashing). True when the button is pressed this frame.
Declaration
[NonSerialized]
[Tooltip("Hazards flag.")]
public bool hazardLights
Field Value
| Type | Description |
|---|---|
| bool |
highBeamLights
Toggle flag for high beam headlights. True when the button is pressed this frame.
Declaration
[NonSerialized]
[Tooltip("High beams flag.")]
public bool highBeamLights
Field Value
| Type | Description |
|---|---|
| bool |
horn
Horn button state. True while the horn button is held down, false when released.
Declaration
[NonSerialized]
[Tooltip("Horn flag.")]
public bool horn
Field Value
| Type | Description |
|---|---|
| bool |
inputSwappedBrakes
Brake value adjusted for reverse gear when swapInputInReverse is enabled. In reverse gear, this contains the throttle input value to make reversing more intuitive. In forward gears, this equals the brake input.
Declaration
[HideInInspector]
[Tooltip("Can represent throttle or brake input, depending on the travel direction of the vehicle.")]
public float inputSwappedBrakes
Field Value
| Type | Description |
|---|---|
| float |
inputSwappedBrakesRaw
Raw version of inputSwappedBrakes without modifications or smoothing.
Declaration
[HideInInspector]
[Tooltip("Same as inputSwappedBrakes but without any modifications. Raw user input.")]
public float inputSwappedBrakesRaw
Field Value
| Type | Description |
|---|---|
| float |
inputSwappedThrottle
Throttle value adjusted for reverse gear when swapInputInReverse is enabled. In reverse gear, this contains the brake input value to make reversing more intuitive. In forward gears, this equals the throttle input.
Declaration
[HideInInspector]
[Tooltip("Can represent throttle or brake input, depending on the travel direction of the vehicle.")]
public float inputSwappedThrottle
Field Value
| Type | Description |
|---|---|
| float |
inputSwappedThrottleRaw
Raw version of inputSwappedThrottle without modifications or smoothing.
Declaration
[HideInInspector]
[Tooltip("Same as inputSwappedThrottle but without any modifications. Raw user input.")]
public float inputSwappedThrottleRaw
Field Value
| Type | Description |
|---|---|
| float |
leftBlinker
Toggle flag for left turn signal. True when the button is pressed this frame.
Declaration
[NonSerialized]
[Tooltip("Left blinker flag.")]
public bool leftBlinker
Field Value
| Type | Description |
|---|---|
| bool |
lowBeamLights
Toggle flag for low beam headlights. True when the button is pressed this frame.
Declaration
[NonSerialized]
[Tooltip("Low-beam light flag.")]
public bool lowBeamLights
Field Value
| Type | Description |
|---|---|
| bool |
rightBlinker
Toggle flag for right turn signal. True when the button is pressed this frame.
Declaration
[NonSerialized]
[Tooltip("Right blinker flag.")]
public bool rightBlinker
Field Value
| Type | Description |
|---|---|
| bool |
shiftDown
Sequential gear shift down flag. True when the shift down button is pressed this frame. Shifts to the next lower gear in sequential transmissions.
Declaration
[NonSerialized]
[Tooltip("Shift-down flag.")]
public bool shiftDown
Field Value
| Type | Description |
|---|---|
| bool |
shiftInto
Direct gear selection for H-pattern shifters. NO_SHIFT indicates no gear selected. Values range from -1 (reverse) through 0 (neutral) to positive integers for forward gears.
Declaration
[NonSerialized]
[Tooltip("Shift into gear. -999 means no shift.")]
public int shiftInto
Field Value
| Type | Description |
|---|---|
| int |
shiftUp
Sequential gear shift up flag. True when the shift up button is pressed this frame. Shifts to the next higher gear in sequential transmissions.
Declaration
[NonSerialized]
[Tooltip("Shift up flag.")]
public bool shiftUp
Field Value
| Type | Description |
|---|---|
| bool |
steering
Steering input normalized to [-1, 1] range, where -1 is full left and 1 is full right. This value may be modified by input smoothing or modification callbacks.
Declaration
[Range(-1, 1)]
[NonSerialized]
[ShowInTelemetry(-1, 1, "0.00", null, 1)]
[Tooltip("Steering input. Range is -1 to 1.")]
public float steering
Field Value
| Type | Description |
|---|---|
| float |
steeringRaw
Raw steering input directly from the input provider without any modifications or smoothing.
Declaration
[HideInInspector]
[Tooltip("Same as steering but without any modifications. Raw user input.")]
public float steeringRaw
Field Value
| Type | Description |
|---|---|
| float |
throttle
Throttle input normalized to [0, 1] range, where 0 is no throttle and 1 is full throttle. This value may be modified by input smoothing or modification callbacks.
Declaration
[Range(0, 1)]
[NonSerialized]
[ShowInTelemetry(0, 1, "0.00", null, 1)]
[Tooltip("Throttle input. The range is 0 to 1.")]
public float throttle
Field Value
| Type | Description |
|---|---|
| float |
throttleRaw
Raw throttle input directly from the input provider without any modifications or smoothing.
Declaration
[HideInInspector]
[Tooltip("Same as throttle but without any modifications. Raw user input.")]
public float throttleRaw
Field Value
| Type | Description |
|---|---|
| float |
trailerAttachDetach
Toggle flag for attaching or detaching trailers. True when the button is pressed this frame. Only functional when TrailerHitchModule is present and enabled.
Declaration
[NonSerialized]
[Tooltip("Trailer attach/detach flag. Only active if there is a trailer module present.")]
public bool trailerAttachDetach
Field Value
| Type | Description |
|---|---|
| bool |
Methods
Reset()
Returns every input to neutral. Run on initialization and on vehicle disable so a re-enabled vehicle does not inherit held inputs.
Declaration
public void Reset()