SetElementCollisionsEnabled
From Multi Theft Auto: Wiki
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: Vehicles that are collisionless and have a driver will cause bugs. |
Note: Enabling a players collisions when they're inside a vehicle will cause bugs. |
Note: Disabling a peds collisions will cause some problems, such as it being unable to move. |
Syntax
bool setElementCollisionsEnabled ( element theElement, bool enabled )
OOP Syntax Help! I don't understand this!
- Method: element:setCollisionsEnabled(...)
- Variable: .collisions
- Counterpart: getElementCollisionsEnabled
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
Returns true if the collisions were set succesfully, false otherwise.
Example
This example disables collisions for all vehicles within a certain radius of a player:
function disableVehicleCollisionsNearPlayer(thePlayer, maxDistance) local playerX, playerY, playerZ = getElementPosition(thePlayer) local vehicles = getElementsByType("vehicle") for k,v in ipairs(vehicles) do local vehicleX, vehicleY, vehicleZ = getElementPosition(v) -- get the distance between the player and the vehicle: local distance = getDistanceBetweenPoints3D(vehicleX, vehicleY, vehicleZ, playerX, playerY, playerZ) if (distance <= maxDistance) then -- disable collisions for the vehicle setElementCollisionsEnabled(v, false) end end end
See Also
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementBoundingBox
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementColShape
- getElementCollisionsEnabled
- getElementData
- getElementDimension
- getElementDistanceFromCentreOfMassToBaseOfModel
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRadius
- getElementRotation
- getElementType
- getElementVelocity
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementCollidableWith
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLocal
- isElementLowLOD
- isElementOnScreen
- isElementStreamable
- isElementStreamedIn
- isElementSyncer
- isElementWaitingForGroundToLoad
- isElementWithinColShape
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollidableWith
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementMatrix
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementStreamable
- setElementVelocity
- setLowLODElement