RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

server/commands - Camera & Input Commandsge_utils - Game Engine Utility Functionsmain.lua - GE Lua Entry Point & Game Loopmap.lua - Navigation Graph (AI Road Map)screenshot.lua - Screenshot Systemserver/server - Level Loading & Game ServerserverConnection - Client-Server Connection Manager`setSpawnpoint` - Default Spawn Point Persistence`simTimeAuthority` - Simulation Time & Bullet Time Control`spawn` - Vehicle Spawning & Safe Placement`suspensionFrequencyTester` - Suspension Natural Frequency Analysis
ui/ambientSound - Ambient Sound Stream PlayerUI Apps ManagerUI AudioBindings LegendCamera Distance AppConsole (consoleNG)Credits MusicExternal App (WebSocket UI Server)Fade ScreenGame BlurGameplay App ContainersGrid SelectorLivery EditorMessages DebuggerMessages/Tasks App ContainersMission InfoPolice InfoTop BarUI ModsUI Navigation / MapVehicle Paint EditorVehicle Vicinity AppUI Visibility

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 Extensionsui

Camera Distance App

Debug app that displays the distance between the camera and the player vehicle.

Debug app that displays the distance between the camera and the player vehicle.


Overview

ui_cameraDistanceApp is a simple debug extension that calculates and displays the distance between the camera and the player vehicle each frame.

Extension path: lua/ge/extensions/ui/cameraDistanceApp.lua


Exports (M)

FunctionSignatureDescription
onUpdate(dtReal, dtSim, dtRaw)Per-frame hook: computes distance and sends to UI.

Internals

Per-Frame Logic

local function onUpdate(dtReal, dtSim, dtRaw)
  local veh = getPlayerVehicle(0)
  if not veh then
    guihooks.trigger('cameraDistance', -1, "no vehicle")
    return
  end
  local vehPos = veh:getPosition()
  local camPos = core_camera.getPosition()

  -- Debug sphere at vehicle position
  debugDrawer:drawSphere(vehPos, 0.5, sphereColor)
  debugDrawer:drawTextAdvanced(vehPos, "camera distance target", textColor, true, false, textBackgroundColor)

  local distance = vehPos:distance(camPos)
  guihooks.trigger('cameraDistance', distance)
end

UI Communication

Sends distance via guihooks.trigger('cameraDistance', distance). When no vehicle exists, sends -1 with "no vehicle" message.

Debug Visualization

Draws a red sphere (radius 0.5) and text label at the vehicle position in 3D world space using debugDrawer.


How It Works

  1. Each frame, gets player vehicle position and camera position
  2. Calculates Euclidean distance between them
  3. Triggers cameraDistance guihook with the value
  4. Draws a debug sphere at the vehicle for visual reference

Additional Exports

The following exports are available but not yet documented in detail:

  • M.onUpdate

Bindings Legend

HUD overlay showing contextual input bindings with modifier support, vehicle-specific actions, and auto-fade.

Console (consoleNG)

In-game developer console with log filtering, command execution, and virtual scrolling.

On this page

OverviewExports (M)InternalsPer-Frame LogicUI CommunicationDebug VisualizationHow It WorksAdditional Exports