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 Directly To

- **Node Name:** `AI Directly To`

Overview

  • Node Name: AI Directly To
  • Category: custom (duration + once behavior)
  • File: extensions/flowgraph/nodes/vehicle/ai/directlyTo.lua

Drives a vehicle directly toward a target position using scripted AI path following. Unlike waypoint-based navigation, this generates a straight-line path divided into steps. Outputs flow once the vehicle arrives within minDistance.

Pin Schema

Input Pins

PinTypeDefaultDescription
flowflow-Inflow for the node
resetflow (impulse)-Resets the node state
vehIdnumber-Vehicle ID (uses player vehicle if empty)
targetvec3-World position to drive to
targetVelocitynumber-Target speed while driving (m/s)

Output Pins

PinTypeDescription
flowflowOutflow - active once the vehicle has arrived

Internals

Key Methods

MethodDescription
init()Sets up state flags and data defaults
reset()Clears started/complete flags and stops the AI
getVeh()Resolves vehicle by ID or player vehicle
setupAI()Generates a straight-line path and starts ai.startFollowing()
endAI()Calls ai:scriptStop() with optional handbrake/wheel straightening
work()Monitors distance to target, transitions to complete

Data Fields (auto-serialized)

FieldDefaultDescription
minDistance1.5Arrival distance threshold (meters)
handBrakeWhenFinishedfalseApply handbrake on arrival
straightenWheelsWhenFinishedfalseStraighten wheels on arrival
maxStepDistance5Maximum distance between path waypoints

Path Generation

  1. Computes the direction vector from vehicle position to target.
  2. Divides the path into steps of at most maxStepDistance.
  3. Creates steps + 3 extra path points beyond the target (overshoot buffer).
  4. Each point includes {x, y, z, t} where t = distance / speed.
  5. Sends path via ai.startFollowing(path, nil, 0, "neverReset").

How It Works

  1. On first flow, calls setupAI() to generate and send the path.
  2. Each subsequent frame, checks squared distance from vehicle to target.
  3. When distance < minDistance², calls endAI() and sets complete = true.
  4. Once complete, outputs flow on the flow output pin.
  5. The reset impulse pin restarts the entire process.

Usage Example

-- Drive vehicle to a specific world position:
-- vehId = vehicleId
-- target = {100, 200, 30}
-- targetVelocity = 10  (10 m/s ≈ 36 km/h)

-- Wait for arrival then trigger next action:
-- Connect flow output → next node in sequence

-- Reset to drive to a new position:
-- Send impulse to 'reset', then update 'target'

Key Dependencies

  • ai.startFollowing() - scripted path following
  • ai:scriptStop() - stops scripted AI driving

See Also

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

AI Chase

- **Node Name:** `AI Chase`

AI Disable

- **Node Name:** `AI Disable`

On this page

OverviewPin SchemaInput PinsOutput PinsInternalsKey MethodsData Fields (auto-serialized)Path GenerationHow It WorksUsage ExampleKey DependenciesSee Also