setElementCollisionsEnabled | Multi Theft Auto: Wiki Skip to content

setElementCollisionsEnabled

Client-side
Server-side
Shared

Pair: getElementCollisionsEnabled

This function can disable or enable an element's collisions. An element without collisions does not interact with the physical environment and remains static.

Note

If you want to disable collisions only with specific elements, use setElementCollidableWith.

Caution
  • Vehicles that are collisionless and have a driver will cause bugs.
  • Enabling a players collisions when they're inside a vehicle will cause bugs.
  • Disabling a peds collisions will cause some problems, such as it being unable to move or wrong rotation after creation.

OOP Syntax Help! I don't understand this!

  • Method:element:setCollisionsEnabled(...)
  • Variable: .collisions

Syntax

bool setElementCollisionsEnabled ( ​element theElement, ​bool enabled )
Required Arguments
  • theElement: The element you wish to set the collisions of.
  • enabled: A boolean to indicate whether collisions are enabled (true) or disabled (false).

Returns

  • bool: result

Returns true if the collisions were set succesfully, false otherwise.

Code Examples

shared
OOP Required
local obj = Object(1337, 0, 0, 3)
obj.collisions = false

See Also

Element Functions