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

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

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 police system.


Role Properties

PropertyValueDescription
class"emergency"Vehicle class category
keepActionOnRefreshtruePreserves pursuit state through respawn
drivability0.5Reduced spawn drivability
personalityModifiers.aggressionoffset +0.1Slightly more aggressive

Actions

ActionDescription
pursuitStartBegins pursuit: sets chase/follow mode, siren, and modifies respawn values
pursuitEndEnds pursuit: stops vehicle, starts cooldown timer, resets flags
chaseTargetSwitches to aggressive chase mode (no lane restriction)
avoidTargetTemporarily flees to dodge head-on collision
roadblockStops vehicle in position as a roadblock
pullOverInherited from base - pulls to side of road
disabledInherited from base - permanent stop with hazards

Key Methods

checkTarget() → id|nil

Scans all traffic vehicles for the best pursuit target (highest pursuit score, non-police).

onRefresh()

Re-evaluates targets on refresh. If a pursuit target exists, restarts pursuit. Checks roadblock distance to avoid re-triggering.

onTrafficTick(dt)

  • Updates validTargets table with distance, interactive distance, and visibility for each potential target
  • Tracks police visibility for pursuit score counting
  • Manages lane-change behavior during chase (exits lane mode when target is visible)
  • Triggers crash avoidance when approaching target head-on at combined speed ≥ avoidSpeed
  • Auto-disables if vehicle takes critical damage
  • Controls traffic signal freezing when lightbar is active

onUpdate(dt, dtSim)

  • Manages siren pulse logic (passive mode → intermittent sirens → full sirens if target accelerates)
  • Handles cooldown timer after pursuit ends
  • Chase state machine: pulls over when near slow target, resumes chase when target moves
  • Exits roadblock mode when target evades or drives away

Internals

Pursuit Modes (from target vehicle)

ModeBehavior
0No pursuit
1Passive - follow with intermittent sirens
2+Aggressive - full chase with continuous sirens

State Flow

none → pursuitStart → (chase ↔ follow ↔ flee ↔ pullOver) → pursuitEnd → disabled → (cooldown) → none

Cooldown

After a pursuit ends, the police vehicle enters a cooldown period (arrestTime + 5 seconds minimum 10s) during which it won't pursue new targets.


Usage Example

-- Police vehicles are auto-assigned this role based on config type
-- Manual assignment:
local veh = gameplay_traffic.getTrafficData()[vehId]
veh:setRole('police')

-- Start pursuit programmatically
veh.role:setTarget(suspectId)
veh.role:setAction('pursuitStart', {targetId = suspectId})

See Also

  • gameplay/traffic/roles/empty - Empty Traffic Role - Related reference
  • gameplay/traffic/roles/standard - Standard Civilian Traffic Role - Related reference
  • gameplay/traffic/roles/suspect - Suspect Traffic Role - Related reference
  • Gameplay Systems Guide - Guide

Empty Traffic Role

Reference for the `empty` traffic role, a minimal role that prevents extra actions or AI logic from being applied to a vehicle. Used when a vehicle needs to be in the traffic system but should not hav

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

On this page

Role PropertiesActionsKey MethodscheckTarget() → id|nilonRefresh()onTrafficTick(dt)onUpdate(dt, dtSim)InternalsPursuit Modes (from target vehicle)State FlowCooldownUsage ExampleSee Also