Input System
Table of Contents
Overview
RCCP's input system supports multiple input methods through a centralized RCCP_InputManager singleton. It handles keyboard, gamepad, mobile touch, gyroscope, and virtual steering wheel input, and is compatible with both Unity's legacy Input Manager and the new Input System package.
Input Architecture
RCCP_InputManager (singleton, reads hardware input)
↓ provides RCCP_Inputs struct
RCCP_Input (per-vehicle component, processes and applies inputs)
↓ vehicle-specific values
RCCP_CarController (uses processed inputs for driving)
- RCCP_InputManager reads raw input from the hardware (keyboard, gamepad, touch screen) and populates an
RCCP_Inputsstruct with normalized values - RCCP_Input (on each vehicle) fetches these values and applies vehicle-specific processing: auto-reverse, steering limiters, counter-steering, throttle cut during shifts
- The processed inputs drive the engine, gearbox, brakes, steering, and other systems
Default Controls
Keyboard
| Action | Key |
|---|---|
| Accelerate | W or Up Arrow |
| Brake / Reverse | S or Down Arrow |
| Steer Left | A or Left Arrow |
| Steer Right | D or Right Arrow |
| Handbrake | Space |
| NOS | Left Shift |
| Clutch | Left Ctrl |
| Start / Stop Engine | I |
| Headlights (Low) | L |
| Headlights (High) | K |
| Left Indicator | Q |
| Right Indicator | E |
| Hazard Lights | Z |
| Gear Up | Left Shift (manual) |
| Gear Down | Left Ctrl (manual) |
| Change Camera | C |
| Look Back | B |
| Record | R |
| Replay | T |
Gamepad
| Action | Button |
|---|---|
| Accelerate | Right Trigger |
| Brake | Left Trigger |
| Steer | Left Stick (horizontal) |
| Handbrake | A / Cross |
| NOS | B / Circle |
| Gear Up | Right Bumper |
| Gear Down | Left Bumper |
| Change Camera | Y / Triangle |
| Look Around | Right Stick |
RCCP automatically detects the connected gamepad type and displays appropriate button icons (Xbox, PlayStation, etc.) via the RCCP_GamepadIcons system.
Mobile
RCCP supports four mobile input modes:
| Mode | Description |
|---|---|
| TouchScreen | On-screen buttons for throttle, brake, steering |
| Gyro | Device tilt controls steering, on-screen throttle/brake |
| SteeringWheel | Virtual steering wheel with on-screen pedals |
| Joystick | Virtual joystick for steering, on-screen throttle/brake |
Set the mobile controller type via:
RCCP.SetMobileController(RCCP_Settings.MobileController.SteeringWheel);
Or through the RCCP Settings asset.
Input Processing
The RCCP_Input component applies several processing steps to raw input before it reaches the vehicle:
Auto-Reverse
When using automatic transmission, if the player holds brake while the vehicle is nearly stopped, the vehicle automatically shifts into reverse and the brake input becomes throttle.
Counter-Steering
When the vehicle is sliding, a configurable counter-steering factor automatically applies slight corrective steering opposite to the slide direction. This makes the vehicle easier to control without requiring expert input.
Steering Limiter
At speeds above approximately 15 km/h, if the wheels are slipping significantly, the maximum steering angle is reduced to prevent violent spins. This works in conjunction with the speed-based steering curve from the behavior preset.
Throttle Cut During Shifts
During gear changes, throttle input is temporarily zeroed to simulate the real-world power interruption during a gear shift.
Speed-Based Steering
The behavior preset defines a steering curve that reduces the maximum steering angle at higher speeds. This prevents unrealistically sharp turns at highway speeds.
Input Overriding
You can bypass the normal input pipeline entirely to control a vehicle from your own script, AI system, or network synchronization:
// Create custom inputs
RCCP_Inputs customInputs = new RCCP_Inputs();
customInputs.throttleInput = 0.8f; // 80% throttle
customInputs.steerInput = 0.3f; // Slight right turn
customInputs.brakeInput = 0f;
// Apply to a vehicle
vehicle.Inputs.OverrideInputs(customInputs);
// Later, restore normal input
vehicle.Inputs.DisableOverrideInputs();
Override Flags
| Flag | Description |
|---|---|
overridePlayerInputs | Skip RCCP_InputManager, use custom RCCP_Inputs |
overrideExternalInputs | Skip post-processing (steering limiter, auto-reverse, etc.) |
Input Rebinding
Players can remap controls at runtime. The rebinding system saves and loads custom key mappings automatically if autoSaveLoadInputRebind is enabled in RCCP Settings.
UI Integration
RCCP_UI_RebindInput— UI component for rebinding a single actionRCCP_UI_RebindInputReset— Resets all bindings to defaultsRCCP_RebindSaveLoad— Handles persistence of rebind data
Input Values
All input values are normalized to standard ranges:
| Input | Range | Description |
|---|---|---|
| Throttle | 0 to 1 | 0 = no gas, 1 = full throttle |
| Brake | 0 to 1 | 0 = no brake, 1 = full brake |
| Steering | -1 to 1 | -1 = full left, 1 = full right |
| Handbrake | 0 to 1 | 0 = released, 1 = fully engaged |
| Clutch | 0 to 1 | 0 = released, 1 = fully pressed |
| NOS | 0 to 1 | 0 = off, 1 = full NOS |
Events
The input system fires events that you can subscribe to:
// Gear shift events
RCCP_InputManager.OnGearShiftedUp += () => { /* gear up */ };
RCCP_InputManager.OnGearShiftedDown += () => { /* gear down */ };
Next Steps
- 08_AISystem.md — AI driving with input overrides
- 13_API.md — Full scripting API reference