Vehicle Input Handler
Central input management system that handles vehicle control inputs from various sources including keyboard/mouse, gamepad, mobile touch, and custom input providers.
Auto Set Input
When autoSetInput is enabled (default), the vehicle automatically retrieves input from all available InputProviders in the scene. Disable this to manually set input through external scripts for AI controllers or replay systems.
Input Properties
Main analog input axes (all values 0-1 or -1 to 1):
| Property | Description |
|---|---|
Vertical |
Combined throttle/brake as single axis. Positive = throttle, negative = brakes |
Steering |
Steering input [-1 to 1]. Left = -1, Right = 1 |
Throttle |
Separate throttle axis [0-1]. Use for split-axis control |
Brakes |
Separate brake axis [0-1]. Use for split-axis control |
Clutch |
Clutch pedal [0-1] |
Handbrake |
Handbrake/parking brake [0-1] |
Raw unprocessed input values are also available via states.throttleRaw, states.brakesRaw, states.steeringRaw, etc.
Steering Smoothing
Smooths binary keyboard input into analog-like steering:
| Property | Description |
|---|---|
steeringSmoothingTime |
Time to reach full steering from zero. Set to 0 to disable. Recommended: 0.15-0.25s |
steeringReturnTime |
Time for steering to return to center when released |
steeringDirectionChangeMultiplier |
Speed multiplier when changing direction (1-5x). Higher = snappier |
Input Swapping
When swapInputInReverse is enabled (default), throttle and brake inputs swap in reverse gear for intuitive controls:
- Throttle input = move backward when in reverse
- Brake input = slow down when reversing
Access swapped values:
| Property | Description |
|---|---|
InputSwappedThrottle |
Returns correct input based on current gear |
InputSwappedBrakes |
Returns correct input based on current gear |
IsInputSwapped |
True when inputs are currently swapped |
Digital Inputs
Boolean inputs for vehicle functions (true when pressed this frame, unless noted):
| Input | Description |
|---|---|
ShiftUp/ShiftDown |
Sequential gear shifting |
ShiftInto |
Direct gear selection. -999 = no gear selected |
EngineStartStop |
Engine ignition toggle |
Horn |
Horn button (true while held) |
LeftBlinker/RightBlinker |
Turn signals |
LowBeamLights/HighBeamLights |
Headlights |
HazardLights |
Hazard lights |
ExtraLights |
Fog/work lights |
CruiseControl |
Cruise control |
Boost |
Boost/nitrous (true while held) |
TrailerAttachDetach |
Trailer coupling |
FlipOver |
Vehicle flip request |
Input Modification
Use inputModifyCallback UnityEvent to modify input values after they're retrieved from InputProviders but before the vehicle uses them. Useful for custom input filters or effects.
Scripting
Manually control input (AI, replay systems):
vehicleController.input.autoSetInput = false;
vehicleController.input.Vertical = 1f; // Full throttle
vehicleController.input.Steering = 0.5f; // Turn right
Read current input values:
float throttle = vehicleController.input.Throttle;
float steering = vehicleController.input.Steering;
bool isSwapped = vehicleController.input.IsInputSwapped;
Reset shift flags after processing (prevents repeated shifts):
vehicleController.input.ResetShiftFlags();