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
Crash DetectionDamage AssessmentGround ContactSorted List

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 Extensionsgameplayutil

Damage Assessment

Reference for `gameplay_util_damageAssessment`, which provides spatial damage analysis by dividing a vehicle's bounding box into a 3×3×3 grid (27 sections) and determining which body regions sustained

Reference for gameplay_util_damageAssessment, which provides spatial damage analysis by dividing a vehicle's bounding box into a 3×3×3 grid (27 sections) and determining which body regions sustained damage.


Module Exports (M)

Core Functions

FunctionSignatureDescription
getSectionsDamageInfoRaw(vehId?) → tableReturns raw beam and collision damage per section (0–26)
getTextualCollisionDamageLocations(data?) → tableReturns named damage locations from collision damage
getTextualBeamDamageLocations(data?) → tableReturns named damage locations from beam/deformation damage
getOverallDamageLevel(vehId) → tableReturns severity name and level (0–3)
calculateDamageVariation(tableNumbers, maxValue?) → numberNormalized standard deviation of damage values (0–1)

Debug

FunctionSignatureDescription
setDebug(bool)Toggle debug visualization (wireframe grid + damage values)

Extension Lifecycle

ExportSignatureDescription
onUpdate(dtReal, dtSim, dtRaw)Per-frame damage data collection from tracked vehicles
onSerialize() → tableSerialize tracking state for save
onDeserialized(data)Restore tracking state from saved data

Internals

Section Grid

The vehicle's oriented bounding box (OOBB) is divided into 27 sections (3×3×3 grid) using non-uniform cell sizes. Outer cells use a cutDepth calculated from the median axis, creating thinner edge cells and a larger center.

Each section provides:

{
  sectionBeamDamage = number,     -- deformation/beam damage
  sectionCollisionDamage = number -- collision force damage
}

Named Damage Locations

LocationCell IDsDescription
Front Center3, 4, 5Center front
Front Left6, 7, 8Left front
Front Right0, 1, 2Right front
Left Center15, 16, 17Left side
Right Center9, 10, 11Right side
Rear Left26, 25, 24Left rear
Rear Right20, 19, 18Right rear
Rear21, 22, 23Center rear
Top2,5,8,11,14,17,20,23,26Top surface
Bottom0,3,6,9,12,15,18,21,24Bottom surface
Front0–8Entire front
Rear18–26Entire rear
Right0,1,2,9,10,11,18,19,20Entire right
Left6,7,8,15,16,17,24,25,26Entire left

Damage Severity Levels

ThresholdNameSeverity
< 50No damage0
≥ 50Minor1
≥ 10,000Moderate2
≥ 30,000Severe3
M.calculateDamageVariation(tableNumbers, maxValue)-
M.getOverallDamageLevel(vehId)-
M.getSectionsDamageInfoRaw(vehId)-
M.getTextualBeamDamageLocations(data)-
M.getTextualCollisionDamageLocations(data)-
M.onDeserialized(data)-
M.onSerialize()-
M.onUpdate()-
M.setDebug(newDebug)-

Damage Score Algorithm

For each named location, computes:

  1. totalDamage - Sum of cell damage differences (new vs old)
  2. maxCellDamage - Highest single cell damage
  3. averageCellDamage - Mean across location's cells
  4. damageVariation - Normalized standard deviation (concentrated vs spread)
  5. intensity - totalDamage / (maxCellDamage × cell count)
  6. damageScore - intensity × totalDamage × averageCellDamage / 1,000,000

The location with the highest damageScore is reported as mostDamagedLocation.


How It Works

  1. getSectionsDamageInfoRaw() queries per-section beam and collision damage from the engine
  2. getTextualCollisionDamageLocations(data) compares old vs new section state
  3. For each named location, sums the damage difference across its cells
  4. Computes statistical metrics (variation, intensity) to determine the most likely impact zone
  5. Used by crashDetection to annotate impacts with spatial damage info

Usage Example

-- Get current damage sections
local sections = gameplay_util_damageAssessment.getSectionsDamageInfoRaw(vehId)

-- Get textual damage after a crash
local result = gameplay_util_damageAssessment.getTextualCollisionDamageLocations({
  vehId = vehId,
  oldSectionsDamageRaw = savedSections  -- from before crash
})
log("I", "", "Most damaged: " .. (result.mostDamagedLocation or "none"))

-- Quick severity check
local level = gameplay_util_damageAssessment.getOverallDamageLevel(vehId)
log("I", "", level.damageName) -- "Minor", "Moderate", "Severe"

See Also

  • gameplay/util/crashDetection - Vehicle Crash Detection System - Related reference
  • gameplay/util/groundContact - Ground Contact Detection - Related reference
  • gameplay/util/sortedList - Sorted Object List Container - Related reference
  • Gameplay Systems Guide - Guide

Crash Detection

Reference for `gameplay_util_crashDetection`, which tracks vehicle damage in real-time to detect crashes and individual impacts. Provides event hooks for crash start/end and impact start/end, with acc

Ground Contact

Reference for `gameplay_util_groundContact`, a simple utility that checks whether a vehicle is resting on its wheels (right-side-up and touching the ground).

On this page

Module Exports (M)Core FunctionsDebugExtension LifecycleInternalsSection GridNamed Damage LocationsDamage Severity LevelsDamage Score AlgorithmHow It WorksUsage ExampleSee Also