RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Flowgraph Base ModuleFlowgraph Base NodeFlowgraph Base State NodeFlowgraph Node BuilderFlowgraph GraphFlowgraph Group HelperFlowgraph LinkFlowgraph ManagerNew Node TemplateFlowgraph PinFlowgraph States ManagerFlowgraph UtilsFlowgraph Variable Storage
Route Distance (Flowgraph Node)Closest Road (Flowgraph Node)Custom Lua (Flowgraph Node)Distance Between (Flowgraph Node)Waypoints Distance (Flowgraph Node)File Exists (Flowgraph Node)Get First Element of Table (Flowgraph Node)Get Level Data (Flowgraph Node)Get Map Objects IDs by DynField (Flowgraph Node)Get Table Value By Key (Flowgraph Node)GHOST (Flowgraph Node)Hide Loading Screen (Flowgraph Node)Color HSV (Flowgraph Node)Line Point From Xnorm (Flowgraph Node)Load Level (Flowgraph Node)Load Project (Flowgraph Node)On Menu (Flowgraph Node)Perlin Noise (Flowgraph Node)Pop Action Map (Flowgraph Node)Get Project InfoPush Action MapRandom ColorRandom NumberRandom QuaternionRandom VectorRoad PropertiesGet Navgraph RouteRoute PositionTemplate NodeTimeTimed SequenceTo NumberTo StringWorld Editor Open

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 Extensionsflowgraphnodesutil

Distance Between (Flowgraph Node)

- **Node Name:** `Distance Between`

Overview

  • Node Name: Distance Between
  • Category: repeat_instant
  • File: extensions/flowgraph/nodes/util/distanceBetween.lua

Calculates the distance between two positions. Each position can be either a vec3 or a vehicle ID (number). Returns 0 as default when positions are invalid.

Pin Schema

Input Pins

PinTypeDescription
posAnumber/vec3Position A - vehicle ID or vec3 position
posBnumber/vec3Position B - vehicle ID or vec3 position

Output Pins

PinTypeDescription
distancenumberDistance between A and B (0 if invalid)

Internals

Key Methods

MethodDescription
work()Resolves both positions and calculates distance
getPosition(pinInput)Converts input to vec3 - handles both vehicle IDs and vec3 tables

Position Resolution

Input TypeBehavior
numberTreated as vehicle ID - calls getObjectByID(id):getPosition()
table (vec3)Converted via pos:setFromTable(input)
nilReturns nil (distance defaults to 0)

How It Works

  1. getPosition() resolves each input: if it's a number, looks up the vehicle by ID and gets its position; if it's a vec3 table, converts it directly.
  2. If a vehicle ID is invalid, returns vec3(0,0,0) as fallback.
  3. Calculates posB:distance(posA) and outputs the result.

Usage Example

-- Distance between two vehicles:
-- posA = vehicleId1 (number)
-- posB = vehicleId2 (number)
-- → distance = vec3 distance between their positions

-- Distance between vehicle and point:
-- posA = vehicleId (number)
-- posB = {100, 200, 50} (vec3 table)

-- Distance between two points:
-- posA = {0, 0, 0}
-- posB = {100, 0, 0}
-- → distance = 100

-- Equivalent Lua:
local veh = getObjectByID(vehId)
local dist = veh:getPosition():distance(vec3(targetPos))

Key Dependencies

  • getObjectByID() - resolves vehicle IDs to objects
  • vec3:distance() - calculates 3D distance

See Also

  • Route Distance (Flowgraph Node) - Related reference
  • Closest Road (Flowgraph Node) - Related reference
  • Custom Lua (Flowgraph Node) - Related reference
  • FlowGraph Guide - Guide

Custom Lua (Flowgraph Node)

- **Node Name:** `Custom Lua`

Waypoints Distance (Flowgraph Node)

- **Node Name:** `Waypoints Distance`

On this page

OverviewPin SchemaInput PinsOutput PinsInternalsKey MethodsPosition ResolutionHow It WorksUsage ExampleKey DependenciesSee Also