setObjectDynamicPhysics
Server-side
Opts an MTA object into GTA's own rigid-body physics, or back out of it.
Syntax
bool setObjectDynamicPhysics(object theObject, bool enabled)Arguments
theObjectobjectObject created with createObject.
enabledboolWhether the object is simulated by GTA physics.
Returns
true when the state was applied; false for an invalid object.
Ownership and lifecycle
The switch is server-side and travels with the object. Position, rotation, linear velocity and angular velocity are synchronized, so motion survives a syncer change and a stream-out/stream-in cycle. Collision is not generated; the object is simulated with whatever its model already has.
Important behavior
- Once enabled, setElementVelocity and setElementAngularVelocity set real motion instead of being overwritten on the next sync tick.
- The syncer sends position, rotation, linear velocity and angular velocity, so a rolling or spinning object keeps its motion through a syncer change.
- This does not generate collision. The object is simulated with whatever collision its model already has, so a model without useful collision will not behave.
- There is no separate tuning API: a physical object uses GTA's own object properties, so mass, turn mass, air resistance and elasticity come from setObjectProperty.
OOP aliases
object:setDynamicPhysics(enabled)object.dynamicPhysics
Example
local ball = createObject(2114, x, y, z)setObjectDynamicPhysics(ball, true)setElementVelocity(ball, 12, 0, 3)setElementAngularVelocity(ball, 0, 0.4, 0)Where this comes from
SOURCECLuaObjectDefs.cppServer/mods/deathmatch/logic/luadefs/CLuaObjectDefs.cpp INTRODUCED / EXTENDEDd3d1f2bdcRead the commit and why the change was made TEST RESOURCE dynamic-object-physics-harness test-resources/dynamic-object-physics-harness
RELATED NEON APIS
Read the system guide → Continue exploring
← Back to the Neon Lua API · How Dynamic object physics works →