This page explains how to add speed traps and red light cameras to a level.
Speed traps are created from normal level objects:
BeamNGTrigger object that detects vehicles.SpotLight, used as the camera flash.The trigger contains dynamic fields that tell the game what type of speed trap it is and how it should behave.
A speed trap setup usually contains:
BeamNGTrigger
SpotLight
The trigger is the functional part. The light is optional and is only used for a visual flash effect.
When a vehicle enters the trigger, the game checks:
In the World Editor, create a BeamNGTrigger and place it where the speed trap should detect vehicles.
The trigger should:
The trigger only activates for vehicles travelling in its positive local Y direction.
In other words, the trigger has a forward direction. Vehicles travelling the opposite way are ignored.
Make sure the trigger is rotated correctly:
Positive local Y axis = valid travel direction
If the speed trap does not trigger, the trigger may be facing the wrong way.
Select the BeamNGTrigger and add the following dynamic fields.
| Field | Value | Description |
|---|---|---|
speedTrapType |
speed |
Marks this trigger as a speed trap. |
speedLimit |
Number, in m/s | Speed limit used by the trap. |
| Field | Value | Description |
|---|---|---|
speedLimitTolerance |
Number, in m/s | Extra speed above the limit before the trap triggers. |
speedTrapLightName |
Object name | Name of the light object used for the flash effect. |
Example:
speedTrapType = speed
speedLimit = 13.89
speedLimitTolerance = 2.78
speedTrapLightName = speedTrapLight_01
This example represents:
Speed limit: 13.89 m/s ≈ 50 km/h
Tolerance: 2.78 m/s ≈ 10 km/h
Trigger at: 16.67 m/s ≈ 60 km/h
If speedLimitTolerance is not set, the game uses a default tolerance of 10% of the speed limit.
A red light camera also uses a BeamNGTrigger, but with different dynamic fields.
| Field | Value | Description |
|---|---|---|
speedTrapType |
redLight |
Marks this trigger as a red light camera. |
trafficSignalId |
Signal name/id | Traffic signal this camera belongs to. |
| Field | Value | Description |
|---|---|---|
triggerSpeed |
Number, in m/s | Minimum speed required to trigger the camera. |
speedTrapLightName |
Object name | Name of the light object used for the flash effect. |
Example:
speedTrapType = redLight
trafficSignalId = trafficSignal_01
triggerSpeed = 5
speedTrapLightName = redLightCameraFlash_01
If triggerSpeed is not set, the default value is:
5 m/s
The camera only triggers if the linked traffic signal is currently red.
Place the red light camera trigger near the stop line or just after it, depending on the intersection layout.
The trigger should detect vehicles that enter the intersection while moving through the red light.
Recommended setup:
For red light cameras, the trigger needs to know which traffic signal it belongs to.
You can inspect traffic signal IDs by enabling traffic signal debug output from the console:
core_trafficSignals.debugLevel = 2
Use the displayed signal name/id as the value for:
trafficSignalId
Example:
trafficSignalId = trafficSignal_01
Create a light object near the speed trap or camera.
A SpotLight is commonly used, but any suitable light object can be used if it supports being enabled and disabled.
The light should:
speedTrapLightName field.Set the light’s enabled field to:
enabled = false
You can configure the light visually as needed:
For a camera flash, it usually makes sense to use a bright white light with a flare.
Example object name:
speedTrapLight_01
Then set this on the trigger:
speedTrapLightName = speedTrapLight_01
Speed trap values use meters per second.
Useful conversions:
| Speed | Meters per second |
|---|---|
| 30 km/h | 8.33 m/s |
| 50 km/h | 13.89 m/s |
| 60 km/h | 16.67 m/s |
| 80 km/h | 22.22 m/s |
| 100 km/h | 27.78 m/s |
| 120 km/h | 33.33 m/s |
Formula:
km/h ÷ 3.6 = m/s
For mph:
mph × 0.44704 = m/s
Objects:
BeamNGTrigger: speedTrapTrigger_01
SpotLight: speedTrapLight_01
Trigger dynamic fields:
speedTrapType = speed
speedLimit = 22.22
speedLimitTolerance = 2.78
speedTrapLightName = speedTrapLight_01
This creates a speed trap with:
Speed limit: 80 km/h
Tolerance: 10 km/h
Trigger at: 90 km/h
Objects:
BeamNGTrigger: redLightCameraTrigger_01
SpotLight: redLightCameraFlash_01
TrafficSignal: trafficSignal_01
Trigger dynamic fields:
speedTrapType = redLight
trafficSignalId = trafficSignal_01
triggerSpeed = 5
speedTrapLightName = redLightCameraFlash_01
The camera triggers when:
5 m/s.When a configured trigger is entered, the game checks the speed trap data.
For normal speed traps:
speedLimit + speedLimitTolerance.For red light cameras:
triggerSpeed.Speed traps are ignored when the vehicle is too far away from the active camera.
In freeroam, speed trap records may be saved per level.
Records are stored by level and trigger name. Because of this, speed trap trigger names should be unique and stable.
Avoid renaming a speed trap trigger after release unless you intentionally want it to use a new leaderboard entry.
BeamNGTrigger per speed trap or red light camera.speedTrapLightName exactly the same as the light object’s name.Possible causes:
speedTrapType is missing or misspelled.The trigger is rotated incorrectly.
Rotate the BeamNGTrigger so its positive local Y axis points in the intended travel direction.
Possible causes:
speedTrapLightName does not match the light object’s name.Possible causes:
speedTrapType is not set to redLight.trafficSignalId is wrong.triggerSpeed is too high.To add a speed trap:
BeamNGTrigger.speedTrapType = speed.speedLimit in meters per second.speedLimitTolerance.SpotLight and reference it with speedTrapLightName.To add a red light camera:
BeamNGTrigger near the stop line.speedTrapType = redLight.trafficSignalId.triggerSpeed.speedTrapLightName.Was this article helpful?