Dynamic Props
Replaces static forest items with interactive vehicle-based props at runtime using a pooling system. Props are spawned near the player and swapped back to forest items when out of range-enabling destr
Replaces static forest items with interactive vehicle-based props at runtime using a pooling system. Props are spawned near the player and swapped back to forest items when out of range-enabling destructible/interactive street furniture.
Public API
| Function | Signature | Description |
|---|---|---|
M.createDynamicProps | (data) | Creates a DynamicProps pool. data fields: forestItemName, propName, poolSize (default 10), spawnInViewRange (default 100), spawnOffset (default vec3(0,0,0)). |
M.unloadAll | () | Despawns all active props, restores forest items, deletes prop vehicles, and reloads collision. |
M.onUpdate | () | Per-frame: updates camera/player position and ticks all DynamicProps pools. |
M.westCoastPole | () | Preset: replaces pole_city1 forest items with streetlight props (pool 1, range 100 m). |
M.westCoastBin | () | Preset: replaces postbox_blue forest items with trashbin props (pool 9, range 150 m). |
DynamicProps Object (Internal)
| Method | Description |
|---|---|
DynamicProps:new(data) | Constructor; sets up pool parameters. |
DynamicProps:spawnProps() | Spawns poolSize inactive vehicle props. |
DynamicProps:findForestItems() | Scans theForest for matching items, builds a quadtree for spatial queries. |
DynamicProps:onUpdate() | Queries nearby items via quadtree, swaps closest items to props and distant ones back. |
DynamicProps:spawnProp(loc, propId) | Teleports forest item underground, activates prop vehicle at original position. |
DynamicProps:despawnProp(loc) | Deactivates prop, resets broken meshes, restores forest item position. |
DynamicProps:unload() | Despawns all and deletes prop vehicle objects. |
Usage Example
-- Replace mailboxes near the player with destructible trashbin props
core_dynamicProps.createDynamicProps({
forestItemName = "postbox_blue",
propName = "trashbin",
poolSize = 5,
spawnInViewRange = 120,
spawnOffset = vec3(0, 0, 0),
})
-- Later, clean up
core_dynamicProps.unloadAll()Key Details
- Uses
quadtreemodule for efficient spatial queries. - Forest items are moved to
vec3(0, 0, -999)when replaced. be:reloadCollision(false, true)is called after spawn batch.- Props are sorted by distance; only
poolSizenearest are active.
Devices (RGB Peripherals)
Manages RGB lighting on supported peripherals (e.g. keyboards, mice). Sets the BeamNG orange brand color when switching to non-drivable entities (unicycle, props, no vehicle) and resets to vehicle-dri
Environment
Comprehensive environment control: time of day, sky colors, clouds, fog, precipitation, gravity, temperature, and ground model physics. Manages the full weather/environment pipeline for levels.