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
Align For CouplingApply Velocity to VehicleBoost VehicleSet Vehicle ColorsCustom Parts Config ProviderEnter VehicleFlip UprightFreeze VehicleGenerate License PlateGet Vehicle ActiveGet Electrics ValueGet GearboxmodeGet Powertrain DataGravity ForceDistance From GroundHas Coupler TagIs CoupledIs Player UsableKeep VehicleMove Vehicle ToOn Cannon FiredOn Vehicle DestroyedOn Vehicle ResetOn Vehicle SpawnedOn Vehicle SwitchedPlayer UsableRandom Config ProviderRecover In PlaceRemove VehicleTimeline ReplaySet Vehicle ActiveSet Gearbox ModeSet IgnitionSet License PlateSet LightbarSet LightsShift to Gear IndexSpawn VehicleVehicle StatesTeleport To Last RoadToggle Vehicle ControlsMove To ShowroomVehicle TouchProps TouchStatic Object TouchTrack VehicleTrailer Respawn ControlVehicle Config ProviderGet Vehicle DataGet Vehicle DataGet Vehicle BoundsVehicle PingGet Vehicle Wheel Center
AI ParametersAI ArriveAI ChaseAI Directly ToAI DisableAI FleeAI FollowAI Follow WaypointsGet AI ModeAI Go To The End LineAI RandomFollow DecalroadAI StopAI Traffic

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 Extensionsflowgraphnodesvehicleai

AI Follow Waypoints

- **Node Name:** `AI Follow Waypoints`

Overview

  • Node Name: AI Follow Waypoints
  • Category: once_f_duration
  • File: extensions/flowgraph/nodes/vehicle/ai/followWaypoints.lua

Drives a vehicle along a list of navgraph waypoints using AI path following. Supports multiple laps and optional stopping at the finish. Duration state transitions from inactive → started → finished when all laps are complete.

Pin Schema

Input Pins

PinTypeDefaultDescription
navgraphPathtable (navgraphPath)-Array of waypoint names for the AI to follow
vehIdnumber-Vehicle ID (uses player vehicle if empty)
lapCountnumber1Number of laps to drive (hidden)
stopAtFinishbooltrueIf true, AI stops at the last waypoint (hidden)

Output Pins

PinTypeDescription
finalWpstringName of the final waypoint in the route (hidden)

Internals

Key Methods

MethodDescription
init()Calls onNodeReset()
_executionStopped()Calls onNodeReset()
onNodeReset()Clears path, lap counters, and duration state
getVeh()Resolves vehicle by ID or player vehicle
workOnce()Sends the path to the AI via ai.driveUsingPath()
work()Monitors vehicle position to track lap completion

AI Command

ai.driveUsingPath({
  wpTargetList = aiPath,
  wpSpeeds = wpSpeeds,
  noOfLaps = lapCount,
  aggression = 1
})
  • wpSpeeds: If stopAtFinish is false, sets a high speed (100) for the final waypoint.
  • For multi-lap routes, the first waypoint is appended to the path to allow the AI to continue seamlessly.

Lap Tracking

  1. Monitors vehicle proximity to the final waypoint.
  2. When the vehicle enters the final waypoint's radius, increments lapsDone.
  3. Uses lapFlag to prevent double-counting (resets when vehicle is closer to the first waypoint).
  4. When lapsDone == lapCount, sets duration state to finished.

How It Works

  1. On first execution, reads the navgraph path and sends ai.driveUsingPath().
  2. Each frame during started state, checks vehicle position against waypoint positions.
  3. Tracks lap completion by detecting entry into the final waypoint radius.
  4. After all laps complete, transitions to finished duration state.
  5. The finalWp output provides the name of the last waypoint for external monitoring.

Usage Example

-- Drive AI along a route:
-- navgraphPath = {"wp_001", "wp_002", "wp_003", "wp_004"}
-- vehId = aiVehicleId
-- lapCount = 1
-- stopAtFinish = true

-- Multi-lap race:
-- navgraphPath = route from Get Navgraph Route node
-- lapCount = 3
-- stopAtFinish = false (keep speed through finish)

-- Chain with route planning:
-- Get Navgraph Route → navgraphRoute → AI Follow Waypoints navgraphPath

Key Dependencies

  • ai.driveUsingPath() - AI waypoint-based path following
  • map.getMap().nodes - navgraph node data for position/radius checks

See Also

  • AI Parameters (Flowgraph Node) - Related reference
  • AI Arrive (Flowgraph Node) - Related reference
  • AI Chase (Flowgraph Node) - Related reference
  • FlowGraph Guide - Guide

AI Follow

- **Node Name:** `AI Follow`

Get AI Mode

- **Node Name:** `Get AI Mode`

On this page

OverviewPin SchemaInput PinsOutput PinsInternalsKey MethodsAI CommandLap TrackingHow It WorksUsage ExampleKey DependenciesSee Also