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

Waypoints Distance (Flowgraph Node)

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

Overview

  • Node Name: Waypoints Distance
  • Category: repeat_instant
  • File: extensions/flowgraph/nodes/util/distanceRemaining.lua

Calculates the remaining distance from a vehicle to the end of a waypoint path, and determines whether the vehicle is traveling in the correct direction.

Pin Schema

Input Pins

PinTypeDescription
alwaysUpdateflow (hidden)When active, forces distance recalculation every frame regardless of velocity
vehIdnumberID of the tracked vehicle
waypointstableArray of vec3 positions defining the path

Output Pins

PinTypeDescription
distLeftnumberRemaining distance along the waypoint path
rightWayboolWhether the vehicle is traveling in the correct direction
goingRightWayflowFlow when vehicle is going the right way
goingWrongWayflowFlow when vehicle is going the wrong way

Internals

Key Methods

MethodDescription
work()Finds nearest path segment, calculates remaining distance, determines travel direction

Direction Detection

The node uses a velocity threshold of 0.50 to determine direction. If the vehicle speed is below this threshold, it is considered "going the right way" by default. When above the threshold, the dot product of the path direction vector and vehicle velocity is used.

How It Works

  1. Iterates all waypoint line segments and finds the one closest to the vehicle position using distanceToLineSegment.
  2. Projects the vehicle onto that segment using xnormOnLine to find the exact position along the segment.
  3. Sums the distance from the projected point to the end of the current segment, plus all subsequent segment lengths.
  4. Checks direction by comparing the vehicle velocity vector against the path direction (dot product > 0 = right way).
  5. When alwaysUpdate is not set and the vehicle is below the speed threshold, the last computed distance is re-used.

Usage Example

-- In a flowgraph, connect waypoints from a path node:
-- [Get Waypoints] → waypoints → [Waypoints Distance] → distLeft → [Display HUD]
--                   vehId ←── [Player Vehicle ID]
--                              → goingWrongWay → [Show Wrong Way Warning]

Key Dependencies

  • map.objects - provides vehicle position and velocity data
  • vec3 math - distanceToLineSegment, xnormOnLine, dot

Previously Undocumented (Added by Audit)

  • Input Pin: goingRigthWay (any)

See Also

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

Distance Between (Flowgraph Node)

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

File Exists (Flowgraph Node)

- **Node Name:** `File Exists`

On this page

OverviewPin SchemaInput PinsOutput PinsInternalsKey MethodsDirection DetectionHow It WorksUsage ExampleKey DependenciesPreviously Undocumented (Added by Audit)See Also