engineSetCOLData
Rebuilds an existing col element's collision from a Lua table and re-applies it to every model it already replaced.
Syntax
bool engineSetCOLData(col theCol, table collision)Arguments
theColcolA col element, including one created by engineLoadCOL from a table.
collisiontableCollision table of spheres, boxes and meshes.
Table keys
Shapes
spherestableoptionalArray of {position = {x,y,z}, radius = n, material = 0-178}. Radius must be greater than zero.
boxestableoptionalArray of {position = {x,y,z}, size = {x,y,z}, material = 0-178}. position is the centre and size is the full extent, not half-extents.
meshestableoptionalArray of {vertices = flat xyz triplets, indices = flat zero-based triangle triplets, material = 0-178}.
Returns
true when the new collision was built and applied; false when the element has no loaded collision or the rebuild failed.
Ownership and lifecycle
A generated col element behaves like any other MTA col element: it is parented to the calling resource, applied to models with engineReplaceCOL, and released when destroyed or when the resource stops. Rebuilding its data re-applies the new collision to every model it was already replaced into.
- This is the reason to generate collision rather than ship a .col: the new shape lands immediately on objects that are already streamed in.
- Rebuild only when the shape actually changes. Keep a signature of the current dimensions and skip identical frames when the shape is driven by held keys or continuous input.
- The previous collision model is destroyed after the replacement succeeds.
Example
-- Make the same wall taller without creating a new elementengineSetCOLData(col, { boxes = { { position = { 0, 0, 0 }, size = { 4, 0.4, 3 }, material = 1 } },})Where this comes from
Continue exploring
← Back to the Neon Lua API · How Runtime collision generation works →