RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Gameplay AchievementGameplay CityDiscoverForce FieldGarage ModeMarker InteractionParking SystemGameplay Playmode MarkersGameplay PoliceGameplay RallyGameplay Rally LoopGameplay Raw POIsGameplay Skidpad TestSpeed Trap LeaderboardsSpeed Traps and CamerasGameplay StatisticsTaxi Ride SystemTraffic SystemVehicle PerformanceWalking
Base Traffic RoleTraffic UtilitiesTraffic Vehicle
Empty Traffic RolePolice Traffic RoleStandard Traffic RoleSuspect Traffic Role

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 Extensionsgameplaytrafficroles

Standard Traffic Role

Reference for the `standard` traffic role, the default role for civilian traffic vehicles. Implements reactive behavior to collisions and crashes - pulling over, fleeing, following, exchanging insuran

Reference for the standard traffic role, the default role for civilian traffic vehicles. Implements reactive behavior to collisions and crashes - pulling over, fleeing, following, exchanging insurance, and honking.


Actions

ActionDescription
fleePostCrashFlees from crash scene (high aggression, no lane restriction)
followPostCrashFollows/chases the responsible vehicle
askInsuranceStops to exchange insurance info
disabledPermanent stop (critical damage)
pullOverInherited - pulls to side of road

Key Methods

onRefresh()

Resets targeting, generates driver personality profile:

  • Brave drivers (bravery ≥ 0.55) → followPostCrash after collisions
  • Timid drivers (bravery ≤ 0.45) → fleePostCrash after collisions
  • Neutral drivers → just stop

Sets thresholds for minimum damage and collision count to trigger reactions.

onCollision(otherId, data)

Handles direct collision with another vehicle:

  • Assigns fault if self is speeding (≥ 120% of speed limit)
  • Sets event type to "selfCollision", targets the other vehicle
  • Brave drivers may honk horn after delay

onOtherCollision(id1, id2, data)

Witnesses a collision between two other vehicles:

  • Targets the slower vehicle
  • Checks visibility, distance (within 60m interactive), and direction (must be ahead)
  • Brave drivers may honk horn

onCrashDamage(data) / onOtherCrashDamage(otherId, data)

Handles non-collision crash damage (e.g., hitting a wall):

  • Only processes if not already in a collision event
  • Sets event type and targets the other vehicle (for other crash)

onTrafficTick(tickTime)

Main decision-making per 0.25s tick:

  • Auto-disables on critical damage
  • Checks target visibility and proximity
  • crashThreshold events: Multiple collisions → flee or follow based on personality
  • crash events: Pull over, optionally set askInsurance flag
  • Resets state if target moves out of range (120m)
  • Manages traffic signal freezing for emergency config vehicles

onUpdate(dt, dtSim)

Per-frame update:

  • Manages action timer countdown
  • Insurance exchange: When both vehicles stopped and close → exchange, show UI message
  • Follow/flee timeout: Returns to pull-over/insurance mode after timer expires
  • Horn honking: Random delay for horn after being hit

Internals

Driver Event Types

TypeTrigger
selfCollisionDirect collision with another vehicle
otherCollisionWitnessed collision between two others
selfCrashCrash damage without collision
otherCrashWitnessed another vehicle crash

Personality Effects

TraitLow (< 0.45)High (≥ 0.55)
BraveryFlee from collisionsFollow/chase responsible driver
PatienceShort pull-over timesLong pull-over/follow times
AggressionLower base aggressionHigher aggression in flee/follow

Usage Example

-- Standard role is auto-assigned to civilian traffic
-- Check if a vehicle would follow you after collision:
local veh = gameplay_traffic.getTrafficData()[vehId]
local bravery = veh.role.driver.personality.bravery
log("I", "", bravery >= 0.55 and "Will follow" or "Will flee or stop")

See Also

  • gameplay/traffic/roles/empty - Empty Traffic Role - Related reference
  • gameplay/traffic/roles/police - Police Traffic Role - Related reference
  • gameplay/traffic/roles/suspect - Suspect Traffic Role - Related reference
  • Gameplay Systems Guide - Guide

Police Traffic Role

Reference for the `police` traffic role, which implements pursuit behavior including chasing suspects, managing sirens, avoiding head-on collisions, setting up roadblocks, and coordinating with the po

Suspect Traffic Role

Reference for the `suspect` traffic role, which marks a vehicle as a wanted suspect that police will chase. Manages the transition from watched → wanted → fleeing → arrested states.

On this page

ActionsKey MethodsonRefresh()onCollision(otherId, data)onOtherCollision(id1, id2, data)onCrashDamage(data) / onOtherCrashDamage(otherId, data)onTrafficTick(tickTime)onUpdate(dt, dtSim)InternalsDriver Event TypesPersonality EffectsUsage ExampleSee Also