Class InputSystemVehicleInputProvider
Vehicle input provider backed by Unity's Input System package (com.unity.inputsystem), which must be installed. Covers keyboard, gamepad and optional mouse steering, plus H-pattern gear selection on the numeric keys 0-8 with minus for reverse.
Inheritance
Inherited Members
Namespace: NWH.VehiclePhysics2.Input
Assembly: NWH.VehiclePhysics2.dll
Syntax
public class InputSystemVehicleInputProvider : VehicleInputProviderBase
Remarks
Actions live in the VehicleInputActions.inputactions asset. For project-specific controls use runtime rebinding or a project-owned action asset and provider: the shipped VehicleInputActions.cs wrapper is generated from that asset but deliberately frozen, so package import does not rewrite source in the package cache.
Fields
mouseInput
Steer and drive from the mouse instead of keyboard or gamepad. Horizontal position is steering, upper half of the screen is throttle and lower half is brakes.
Declaration
[Tooltip("Should mouse be used for input?")]
public bool mouseInput
Field Value
| Type | Description |
|---|---|
| bool |
vehicleInputActions
Action set shared by every provider instance, generated from VehicleInputActions.inputactions.
Declaration
public static VehicleInputActions vehicleInputActions
Field Value
| Type | Description |
|---|---|
| VehicleInputActions |
Methods
Awake()
Creates the shared VehicleInputActions if needed and hooks the H-shifter, horn and boost callbacks. Enabling the actions is left to OnEnable, so a provider that starts disabled has no input side effects.
Declaration
public override void Awake()
Overrides
Boost()
Returns true while the boost button is held down. Only functional when NOSModule or similar boost module is present and enabled. Provides temporary power increase when active.
Declaration
public override bool Boost()
Returns
| Type | Description |
|---|---|
| bool | True while button is pressed. |
Overrides
Brakes()
Returns the current brake input value normalized to [0, 1] range. 0 means no braking, 1 means full braking force.
Declaration
public override float Brakes()
Returns
| Type | Description |
|---|---|
| float | Brake input value between 0 and 1. |
Overrides
Clutch()
Returns the current clutch input value normalized to [0, 1] range. 0 means clutch fully engaged (pedal released), 1 means clutch fully disengaged (pedal pressed). Used with manual transmissions for gear changes and preventing engine stalls.
Declaration
public override float Clutch()
Returns
| Type | Description |
|---|---|
| float | Clutch input value between 0 and 1. |
Overrides
CruiseControl()
Returns true when the cruise control toggle button is pressed this frame. Only functional when CruiseControlModule is present and enabled. Maintains constant vehicle speed without throttle input.
Declaration
public override bool CruiseControl()
Returns
| Type | Description |
|---|---|
| bool | True if button was pressed this frame. |
Overrides
EngineStartStop()
Returns true when the engine start/stop button is pressed this frame. Toggles the engine on/off state.
Declaration
public override bool EngineStartStop()
Returns
| Type | Description |
|---|---|
| bool | True if button was pressed this frame. |
Overrides
ExtraLights()
Returns true when the extra lights toggle button is pressed this frame. Controls auxiliary lights such as fog lights, work lights, or off-road lights.
Declaration
public override bool ExtraLights()
Returns
| Type | Description |
|---|---|
| bool | True if button was pressed this frame. |
Overrides
FlipOver()
Returns true when the flip-over button is pressed this frame. Only functional when FlipOverModule is present and enabled, used to right overturned vehicles.
Declaration
public override bool FlipOver()
Returns
| Type | Description |
|---|---|
| bool | True if button was pressed this frame. |
Overrides
Handbrake()
Returns the current handbrake input value normalized to [0, 1] range. 0 means released, 1 means fully engaged. Typically used for drifting or parking.
Declaration
public override float Handbrake()
Returns
| Type | Description |
|---|---|
| float | Handbrake input value between 0 and 1. |
Overrides
HazardLights()
Returns true when the hazard lights toggle button is pressed this frame. Activates all turn signals simultaneously for emergency warning.
Declaration
public override bool HazardLights()
Returns
| Type | Description |
|---|---|
| bool | True if button was pressed this frame. |
Overrides
HighBeamLights()
Returns true when the high beam headlights toggle button is pressed this frame. Switches headlights between low beam and high beam mode.
Declaration
public override bool HighBeamLights()
Returns
| Type | Description |
|---|---|
| bool | True if button was pressed this frame. |
Overrides
Horn()
Returns true while the horn button is held down. Unlike toggle buttons, this is typically held for continuous horn sound.
Declaration
public override bool Horn()
Returns
| Type | Description |
|---|---|
| bool | True while button is pressed. |
Overrides
LeftBlinker()
Returns true when the left turn signal button is pressed this frame. Toggles the left turn indicator on/off.
Declaration
public override bool LeftBlinker()
Returns
| Type | Description |
|---|---|
| bool | True if button was pressed this frame. |
Overrides
LowBeamLights()
Returns true when the low beam headlights toggle button is pressed this frame. Turns the main headlights on or off.
Declaration
public override bool LowBeamLights()
Returns
| Type | Description |
|---|---|
| bool | True if button was pressed this frame. |
Overrides
OnDestroy()
Declaration
public override void OnDestroy()
Overrides
OnDisable()
Disables the Input System actions once the last enabled provider is disabled. The action asset is shared, so it stays enabled while any other provider is using it.
Declaration
public void OnDisable()
OnEnable()
Enables the Input System actions when the component is enabled.
Declaration
public void OnEnable()
RightBlinker()
Returns true when the right turn signal button is pressed this frame. Toggles the right turn indicator on/off.
Declaration
public override bool RightBlinker()
Returns
| Type | Description |
|---|---|
| bool | True if button was pressed this frame. |
Overrides
ShiftDown()
Returns true when the sequential shift down button is pressed this frame. Shifts transmission to the next lower gear in sequential mode.
Declaration
public override bool ShiftDown()
Returns
| Type | Description |
|---|---|
| bool | True if button was pressed this frame. |
Overrides
ShiftInto()
Returns the directly selected gear index for H-pattern shifters. Supports numeric keys 0-8 for forward gears, minus key for reverse (-1), and 0 for neutral. Returns -999 if no gear key is currently held.
Declaration
public override int ShiftInto()
Returns
| Type | Description |
|---|---|
| int | Gear index (-1 for reverse, 0 for neutral, 1-8 for forward gears), or -999 if no gear is selected. |
Overrides
ShiftUp()
Returns true when the sequential shift up button is pressed this frame. Shifts transmission to the next higher gear in sequential mode.
Declaration
public override bool ShiftUp()
Returns
| Type | Description |
|---|---|
| bool | True if button was pressed this frame. |
Overrides
Steering()
Returns the current steering input value normalized to [-1, 1] range. -1 means full left, 0 means centered, 1 means full right.
Declaration
public override float Steering()
Returns
| Type | Description |
|---|---|
| float | Steering input value between -1 and 1. |
Overrides
Throttle()
Returns the current throttle input value normalized to [0, 1] range. 0 means no throttle, 1 means full throttle.
Declaration
public override float Throttle()
Returns
| Type | Description |
|---|---|
| float | Throttle input value between 0 and 1. |
Overrides
TrailerAttachDetach()
Returns true when the trailer attach/detach button is pressed this frame. Only functional when TrailerHitchModule is present and enabled on the vehicle.
Declaration
public override bool TrailerAttachDetach()
Returns
| Type | Description |
|---|---|
| bool | True if button was pressed this frame. |
Overrides
Update()
Caches throttle, brakes, steering, clutch and handbrake once per frame. Throttle, brakes and steering come from mouse position instead while mouseInput is on.
Declaration
public void Update()