RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Gameplay AchievementGameplay CityDiscoverForce FieldGarage ModeMarker InteractionParking SystemGameplay Playmode MarkersGameplay PoliceGameplay RallyGameplay Rally LoopGameplay Raw POIsGameplay Skidpad TestSpeed Trap LeaderboardsSpeed Traps and CamerasGameplay StatisticsTaxi Ride SystemTraffic SystemVehicle PerformanceWalking

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API ReferenceGE Extensionsgameplay

Walking

Reference for `gameplay_walk`, which manages the walking mode (first-person on-foot via the "unicycle" vehicle). Handles toggling between walking and driving, entering/exiting vehicles, proximity dete

Reference for gameplay_walk, which manages the walking mode (first-person on-foot via the "unicycle" vehicle). Handles toggling between walking and driving, entering/exiting vehicles, proximity detection, and vehicle blacklisting.


Module Exports (M)

Walking State

FunctionSignatureDescription
isWalking() → boolReturns true if player is on the unicycle
setWalkingMode(enabled, pos?, rot?, force?) → success, unicycleIdToggles walking mode on/off
toggleWalkingMode()Toggle - enters walking or gets in nearby vehicle
getPlayerUnicycle() → veh|nilReturns the unicycle vehicle if player is on it
isAtParkingSpeed() → boolReturns true if current vehicle is slow enough to exit

Vehicle Interaction

FunctionSignatureDescription
getVehicleInFront() → veh|nilReturns the nearest enterable vehicle while walking
getInVehicle(vehicle)Enters a vehicle, deactivates unicycle
getDoorsidePosRot(veh) → pos, front, upCalculates driver-door-side spawn position

Position & Rotation

FunctionSignatureDescription
getPosRot() → pos, quatReturns walking position and camera quaternion
getPosXYZ() → x, y, zReturns walking position components
getRotXYZW() → x, y, z, wReturns camera quaternion components
setRot(front, up)Sets unicycle camera direction

Toggling Control

FunctionSignatureDescription
enableToggling(enabled)Enable/disable walking mode toggle
isTogglingEnabled() → boolCheck if toggling is allowed

Vehicle Blacklist

FunctionSignatureDescription
addVehicleToBlacklist(vehId)Prevent entering this vehicle while walking
removeVehicleFromBlacklist(vehId)Allow entering this vehicle again
isVehicleBlacklisted(vehId) → boolCheck if blacklisted
clearBlacklist()Clear all blacklist entries
getBlacklist() → tableReturns the blacklist table

Hooks / Lifecycle

FunctionDescription
onUpdatePer-frame: checks vehicle proximity, shows enter message, manages unicycle alpha
onSerializeSaves toggling state and blacklist
onDeserializeRestores toggling state and blacklist
onClientStartMissionClears blacklist and re-enables toggling
onVehicleSwitchedUpdates active state, resets unicycle alpha on switch

Internals

Speed Thresholds

ThresholdValueDescription
lowerStoppingSpeed5 km/hBelow this → at parking speed
higherStoppingSpeed6 km/hAbove this → not at parking speed
M.addVehicleToBlacklist(vehId)-
M.clearBlacklist()-
M.enableToggling(enabled)-
M.getBlacklist()-
M.getDoorsidePosRot(veh)-
M.getInVehicle(vehicle)-
M.getPlayerUnicycle(veh)-
M.getPosRot()-
M.getPosXYZ()-
M.getRotXYZW()-
M.getVehicleInFront()-
M.isAtParkingSpeed()-
M.isTogglingEnabled()-
M.isVehicleBlacklisted(vehId)-
M.isWalking()-
M.onClientStartMission(levelPath)-
M.onDeserialize(data)-
M.onSerialize()-
M.onUpdate(dtReal, dtSim)-
M.onVehicleSwitched(oldId, newId, player)-
M.removeVehicleFromBlacklist(vehId)-
M.setRot(front, up)-
M.setWalkingMode(enabled, pos, rot, force)-
M.toggleWalkingMode()-

Hysteresis between the two prevents flickering at the threshold.

Vehicle Proximity Detection

Each frame while walking, the system:

  1. Iterates all vehicles (excluding blacklisted, non-playerUsable, inactive, and unicycles)
  2. Computes bounding-box distance to the player using the vehicle's OOBB
  3. The closest vehicle within 2m becomes vehicleInFront
  4. If that vehicle is at parking speed, shows "enter vehicle" message

Bounding Box Distance

Uses the vehicle's oriented bounding box (OOBB) with 8 corner points. Calculates minimum distance from the player position to all 16 edge segments of the box - more accurate than center-to-center distance for large vehicles.

Unicycle Management

  • The "unicycle" is a special JBeam vehicle used as the walking avatar
  • When entering a vehicle: unicycle is deactivated (physics stopped, hidden)
  • When exiting: unicycle is teleported to the driver's door side
  • In career mode, uses without_mesh.pc config (invisible unicycle)
  • Unicycle mesh alpha fades based on camera distance (invisible in first person)

Driver Door Positioning

getDoorsidePosRot() calculates exit position:

  1. Gets reference nodes (ref, left) for vehicle orientation
  2. Gets driver node position and handedness (LHD/RHD)
  3. Offsets to the door side by initialNodePosBB extents + 0.7m body offset
  4. Returns position looking toward the vehicle center

How It Works

  1. Player presses walk toggle → setWalkingMode(true) fires onBeforeWalkingModeToggled
  2. Unicycle spawned/teleported to driver door side via getOutOfVehicle()
  3. Player enters unicycle, unicycle camera activated
  4. onUpdate checks proximity to vehicles, shows enter message
  5. Player presses toggle near a stopped vehicle → setWalkingMode(false)
  6. Unicycle deactivated, player enters the nearby vehicle

Usage Example

-- Check if player is walking
if gameplay_walk.isWalking() then
  local x, y, z = gameplay_walk.getPosXYZ()
  log("I", "", string.format("Walking at %0.1f, %0.1f, %0.1f", x, y, z))
end

-- Programmatically enter walking mode at a position
gameplay_walk.setWalkingMode(true, vec3(100, 200, 50))

-- Blacklist traffic vehicles from being enterable
gameplay_walk.addVehicleToBlacklist(trafficVehId)

-- Get the vehicle the player is looking at
local veh = gameplay_walk.getVehicleInFront()
if veh then
  log("I", "", "Near vehicle: " .. veh:getJBeamFilename())
end

See Also

  • Gameplay Achievement - Related reference
  • Gameplay City - Related reference
  • discover - Discover / Experience System - Related reference
  • Gameplay Systems Guide - Guide

Vehicle Performance

Reference for `gameplay_vehiclePerformance`, which calculates a Performance Index (PI) from drag test data and assigns vehicles to performance classes (D through X).

G2G Activity

Background activity that spawns random vehicles into the world. Uses a step-based sequence with fade-to-black transitions for vehicle spawning.

On this page

Module Exports (M)Walking StateVehicle InteractionPosition & RotationToggling ControlVehicle BlacklistHooks / LifecycleInternalsSpeed ThresholdsVehicle Proximity DetectionBounding Box DistanceUnicycle ManagementDriver Door PositioningHow It WorksUsage ExampleSee Also