RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Ambient SoundUI Apps ManagerUI AudioBindings LegendCamera Distance AppDeveloper ConsoleCredits MusicExternal WebSocket ServerFade ScreenGame BlurGameplay App ContainersGrid SelectorLivery EditorMessages DebuggerMessages/Tasks App ContainersMission InfoPolice InfoTop BarUI ModsNavigation Map DataVehicle 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

See Also

  • ui/ambientSound - Ambient Sound Stream Player - Related reference
  • UI Apps Manager - Related reference
  • UI Audio - Related reference
  • UI System Guide - Guide

Bindings Legend

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

Developer Console

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

On this page

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