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

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 Extensionsflowgraphnodesvehicle

Align For Coupling

- **Node Name:** `Align for Coupling`

Overview

  • Node Name: Align for Coupling
  • Behaviour: duration, once
  • File: extensions/flowgraph/nodes/vehicle/alignForCoupling.lua

Moves a trailer behind a pulling vehicle so their coupler points align, then optionally enables auto-coupling. Outputs flow once successfully coupled.

Pin Schema

Input Pins

PinTypeDefaultDescription
flowflow-Inflow for this node.
resetflow (impulse)-Resets the node.
vehIdnumber-ID of the pulling vehicle.
trailerIdnumber-ID of the trailer vehicle.
rotnumber/quat0Rotation for the trailer. Number = degrees relative to puller. Quat = absolute/relative rotation (hidden).
relativeRotationQuatbool-If true, quat rotation is relative to the pulling vehicle (hidden).
ignoreCouplebooltrueIf checked, skips automatic coupling activation (hidden).

Output Pins

PinTypeDescription
flowflowFires once vehicles are successfully coupled (or immediately if ignoreCouple).

Internals

Key Methods

MethodDescription
_executionStarted()Resets done, waitForCouple, and coupled flags.
work()Computes coupler alignment matrix, teleports trailer, enables coupling, waits for couple confirmation.

State Flags

FlagDescription
doneAlignment calculation completed.
waitForCoupleWaiting for physical coupling to occur.
coupledCoupling confirmed.

How It Works

  1. Retrieves coupler offset positions for both vehicles from self.mgr.modules.vehicle.
  2. Builds transformation matrices:
    • v1CouplerMatrix - world-space position of the puller's coupler point.
    • v2CouplerMatrix - local coupler offset of the trailer.
  3. Computes a rotation matrix from the rot pin (degrees or quaternion).
  4. Calculates the final trailer transform: v1CouplerMatrix * (rotMatrix * v2CouplerMatrix:inverse() * v2RefMatrix).
  5. Teleports the trailer via v2:setTransform(res) and resets its physics.
  6. Activates auto-coupling on the puller via beamstate.activateAutoCoupling().
  7. Polls mgr.modules.vehicle:isCoupledTo() each frame until coupling is confirmed.
-- The core alignment math:
local result = v1CouplerMatrix * (rotMatrix * v2CouplerMatrix:inverse() * v2:getRefNodeMatrix())
v2:setTransform(result)
v2:queueLuaCommand('obj:requestReset(RESET_PHYSICS)')
v1:queueLuaCommand('beamstate.activateAutoCoupling()')

Usage Example

-- Flowgraph:
-- [Spawn Truck] → vehId ──→ [Align for Coupling] → flow → [Drive Away]
-- [Spawn Trailer] → trailerId ↗
--
-- Optionally rotate trailer 180° relative to truck:
-- rot = 180 (degrees)

Key Dependencies

  • mgr.modules.vehicle:getVehicle(id).couplerOffset - coupler offset data
  • mgr.modules.vehicle:isCoupledTo() - coupling status check
  • beamstate.activateAutoCoupling() - vehicle-side coupling activation
  • MatrixF - 4×4 transformation matrix operations

See Also

  • Apply Velocity to Vehicle (Flowgraph Node) - Related reference
  • Boost Vehicle (Flowgraph Node) - Related reference
  • Set Vehicle Colors (Flowgraph Node) - Related reference
  • FlowGraph Guide - Guide

Save Data (Flowgraph Node)

- **Node Name:** `Save Data`

Apply Velocity to Vehicle

- **Node Name:** `Apply Velocity to Vehicle`

On this page

OverviewPin SchemaInput PinsOutput PinsInternalsKey MethodsState FlagsHow It WorksUsage ExampleKey DependenciesSee Also