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

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 Extensionsgameplay

Gameplay Playmode Markers

Clusters POI data into playmode marker groups (missions, parking, zones, walking, gas stations, drift lines, etc.) and provides spatial queries via a KD-tree for efficient visibility lookups.

Clusters POI data into playmode marker groups (missions, parking, zones, walking, gas stations, drift lines, etc.) and provides spatial queries via a KD-tree for efficient visibility lookups.


Public API

| Function | Signature | Returns | Description | |------ | M.dependencies | table | {"gameplay_rawPois"} |----|-----------|---------|-------------| | M.getPlaymodeClusters | () | table | Returns all playmode clusters for the current level, building them lazily | | M.getPlaymodeClustersAsQuadtree | () | kdtree | Returns a 2D KD-tree of clusters for spatial queries | | M.getMarkerForCluster | (cluster) | marker | Gets or creates the visual marker object for a cluster | | M.isStateWithPlaymodeMarkers | () | bool | Returns true if the current game state shows playmode markers | | M.clear | () | nil | Clears all cached clusters and markers |

Hooks

HookPurpose
M.onClientEndMissionClears clusters on mission end
M.onSerializeClears clusters before serialization

Dependencies

  • gameplay_rawPois

Internals

NameTypeDescription
playmodeClusterstable/nilCached array of cluster objects
playmodeKdkdtree/nilCached 2D KD-tree for spatial lookup
markersByClusterIdtableMap of cluster ID → marker object
playmodeMarkerTypeNamestableSet of known marker type strings
clusterGenerationnumberTracks raw POI generation for cache invalidation

How It Works

  1. getPlaymodeClusters() checks the current POI generation from gameplay_rawPois
  2. If stale, clears existing clusters/markers and re-fetches raw POIs for the current level
  3. POIs are grouped by marker type (mission, parking, zone, etc.)
  4. Each marker type's factory module (gameplay/markers/<type>) clusters its own POIs
  5. All clusters are sorted by ID and validated for required fields (id, visibilityPos, visibilityRadius)
  6. getPlaymodeClustersAsQuadtree() builds a 2D KD-tree using cluster visibility bounds for fast spatial lookup
  7. getMarkerForCluster() lazily creates, sets up, and caches marker objects per cluster

Usage Examples

-- Get all clusters for the level
local clusters = gameplay_playmodeMarkers.getPlaymodeClusters()

-- Spatial query: find clusters near a position
local kd = gameplay_playmodeMarkers.getPlaymodeClustersAsQuadtree()
local nearby = kd:queryBox(x - r, y - r, x + r, y + r)

-- Get the visual marker for a specific cluster
local marker = gameplay_playmodeMarkers.getMarkerForCluster(clusters[1])

-- Check if we should display markers in the current state
if gameplay_playmodeMarkers.isStateWithPlaymodeMarkers() then
  -- show markers
end

Notes

  • Valid states for markers: freeroam and career (configurable via M.validPlaymodeMarkersStates)
  • Generation tracking auto-invalidates caches when raw POIs change
  • Each marker type factory must implement a cluster(pois, allClusters) function

Module Variables

VariableTypeDescription
M.dependenciestable{"gameplay_rawPois"}

See Also

  • Gameplay Achievement - Related reference
  • Gameplay City - Related reference
  • discover - Discover / Experience System - Related reference
  • Gameplay Systems Guide - Guide

Parking System

Reference for `gameplay_parking`, which manages spawning, positioning, and recycling of AI parked vehicles using parking spot site data and vehicle active pooling.

Gameplay Police

Manages police pursuit logic including suspect tracking, arrest/evade timers, roadblock placement, and pursuit mode escalation. Tightly integrated with the traffic system.

On this page

Public APIHooksDependenciesInternalsHow It WorksUsage ExamplesNotesModule VariablesSee Also