Skip to main content

RigidObjectHandle (server)

On the server, a RigidObjectHandle changes how the object moves and whether it collides. These changes are synced to every player who sees it.

Available on: Server

See also: RigidObjectHandle, RigidObjectHandle (client)

Methods​

rigidObject:SetMotionType(motionType)​

Changes how the object moves. Synced to everyone who sees it, including players who come into range later.

Side: Server

Parameters

NameTypeDescription
motionTypeRigidObjectMotionTypeStatic (never moves), Keyframed (moved only by setting its transform, pushes others but is not pushed) or Dynamic (falls and can be pushed, simulated by physics)

Returns: nothing

Notes: a value out of range raises a Lua error.

Example

-- a crate that hangs in the air until someone shoots it
local crate = World.SpawnRigidObject(position, model, pfx, RigidObjectMotionType.Keyframed)

Net.AddEvent("CrateShot", function(netId)
if netId == crate:GetNetId() then
crate:SetMotionType(RigidObjectMotionType.Dynamic)
end
end)

rigidObject:EnableCollision(enable)​

Turns the object's collisions on or off: with collisions off, players, vehicles and other objects pass through it. Synced to everyone who sees it. Collisions are on for a newly spawned object.

Side: Server

Parameters

NameTypeDescription
enablebooleantrue for solid, false to let everything pass through

Returns: nothing

Example

-- a ghost wall that opens for 5 seconds
wall:EnableCollision(false)

Timer.Set(function()
wall:EnableCollision(true)
end, 5000, 1)