Remote Controller
Mobile phone remote controller support. Listens for UDP connections from the BeamNG Remote Control app, creates virtual input devices, and bridges accelerometer/button data to vehicle controls.
Mobile phone remote controller support. Listens for UDP connections from the BeamNG Remote Control app, creates virtual input devices, and bridges accelerometer/button data to vehicle controls.
Public Functions
| Function | Signature | Description |
|---|---|---|
M.onUpdate | () | Processes incoming UDP packets and manages device timeouts |
M.onExtensionLoaded | () → boolean | Validates FFI availability (required for binary parsing) |
M.onInputBindingsChanged | (players) | Updates player assignment for virtual devices |
M.getQRCode | () → number/false | Opens UDP socket and returns the pairing code |
M.devicesConnected | () → boolean | Whether any remote devices are currently connected |
M.onFirstUpdate() | Hook: first update tick. |
Network Protocol
| Port | Direction | Purpose |
|---|---|---|
| 4444 | Listen | Discovery and input data from app |
| 4445 | Send | UI data (outgauge) back to app |
Connection Flow
- App sends:
beamng|<deviceName>|<code> - Server validates code, creates virtual input device
- Server responds:
beamng|<code> - App sends binary orientation data (16 bytes:
{w, x, y, z}as floats)
Input Mapping
| App Data | Virtual Input | Mapping |
|---|---|---|
orientation.x > 0.5 | button 0 | Binary threshold |
orientation.y > 0.5 | button 1 | Binary threshold |
orientation.z | axis 0 | Continuous 0.0–1.0 (steering) |
Module State
| Variable | Type | Default |
|---|---|---|
onFirstUpdate | varies | onFirstUpdate |
Usage Example
-- Get the pairing code (also starts the UDP listener)
local code = core_remoteController.getQRCode()
if code then
print("Pairing code: " .. code)
end
-- Check if any devices are connected
if core_remoteController.devicesConnected() then
print("Remote controller active")
endDevice Lifecycle
- Discovery: Random 5-digit code generated on extension load
- Connection: Virtual input device created via
core_input_virtualInput - Timeout: Devices disconnected after 10 seconds of no packets
- UI Feedback: Vehicle outgauge data sent back to app for dashboard display
Notes
- Requires FFI for binary packet parsing (
ori_tstruct: 4 floats). - Virtual devices are named
"vinput" .. deviceInstance. - Supports multiseat - each remote device can be assigned to a different player.
- The app port is
listenPort + 1(4445 by default). - Network byte order is reversed for the orientation struct.
See Also
- virtualInput - Virtual input device creation
- multiseat - Multi-player input assignment
Recovery Prompt
Recovery and towing system for career mode. Provides context-sensitive buttons for flipping, towing, repairing, and teleporting vehicles, with cost calculations, conditions, and fade-screen transition
Replay
Replay recording and playback system. Records vehicle physics state to `.rpl` files, plays back with variable speed, seeking, and frame stepping. Supports mission auto-recording and user-saved replays