SetElementCollidableWith: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
(add Weapon to supported element types) |
||
(11 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{Client function}} | {{Client function}} | ||
__NOTOC__ | __NOTOC__ | ||
This function can be used to set an element to collide with another element. An element with collisions disabled does not interact physically with the other element.<br> | This function can be used to set an element to collide with another element. An element with collisions disabled does not interact physically with the other element.<br> | ||
Line 7: | Line 7: | ||
*[[Vehicle]] | *[[Vehicle]] | ||
*[[Object]] | *[[Object]] | ||
{{Added feature/item|1.5.9|1.5.8|21348| | |||
* [[Element/Weapon|Weapon]] | |||
}} | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool setElementCollidableWith ( element theElement, element withElement, bool enabled ) | bool setElementCollidableWith ( element theElement, element withElement, bool enabled ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[element]]:setCollidableWith||isElementCollidableWith}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
Line 24: | Line 28: | ||
<section name="Client" class="client" show="true"> | <section name="Client" class="client" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | function ghostmode_on() | ||
local playerVehicle = getPedOccupiedVehicle(localPlayer) -- Get the players vehicle | |||
if(playerVehicle) then -- Check the return value. | |||
for i,v in pairs(getElementsByType("vehicle")) do --LOOP through all vehicles | |||
setElementCollidableWith(v, playerVehicle, false) -- Set the collison off with the other vehicles. | |||
end | |||
outputChatBox("You are now a Ghost") | |||
end | |||
end | |||
addCommandHandler("ghostmode", ghostmode_on) -- Add the /ghostmode Command. | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
Line 30: | Line 43: | ||
==See Also== | ==See Also== | ||
{{Client element functions}} | {{Client element functions}} | ||
Latest revision as of 21:31, 7 October 2022
This function can be used to set an element to collide with another element. An element with collisions disabled does not interact physically with the other element.
Note: You can only use this function with the element types listed below.
Syntax
bool setElementCollidableWith ( element theElement, element withElement, bool enabled )
OOP Syntax Help! I don't understand this!
- Method: element:setCollidableWith(...)
- Counterpart: isElementCollidableWith
Required Arguments
- theElement: The element which colliding you want to change
- withElement: The other element you wish the first entity to collide with
- enabled: A boolean to indicate whether elements should be able to collide with eachother (true) or not (false)
Returns
Returns true if the collisions were set succesfully, false otherwise.
Example
Click to collapse [-]
Clientfunction ghostmode_on() local playerVehicle = getPedOccupiedVehicle(localPlayer) -- Get the players vehicle if(playerVehicle) then -- Check the return value. for i,v in pairs(getElementsByType("vehicle")) do --LOOP through all vehicles setElementCollidableWith(v, playerVehicle, false) -- Set the collison off with the other vehicles. end outputChatBox("You are now a Ghost") end end addCommandHandler("ghostmode", ghostmode_on) -- Add the /ghostmode Command.
See Also
- getElementBoneMatrix
- getElementBonePosition
- getElementBoneRotation
- getElementBoundingBox
- getElementDistanceFromCentreOfMassToBaseOfModel
- getElementLighting
- getElementRadius
- isElementCollidableWith
- isElementLocal
- isElementOnScreen
- isElementStreamable
- isElementStreamedIn
- isElementSyncer
- isElementWaitingForGroundToLoad
- setElementBoneMatrix
- setElementBonePosition
- setElementBoneRotation
- setElementCollidableWith
- setElementStreamable
- updateElementRpHAnim
- Shared
- attachElements
- createElement
- destroyElement
- detachElements
- getAttachedElements
- getElementAlpha
- getElementAttachedOffsets
- getElementAttachedTo
- getElementByIndex
- getElementByID
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getAllElementData
- hasElementData
- getElementDimension
- getElementHealth
- getElementID
- getElementInterior
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementType
- getElementVelocity
- getLowLODElement
- getRootElement
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLowLOD
- isElementWithinColShape
- isElementWithinMarker
- setElementAlpha
- setElementAngularVelocity
- getElementAngularVelocity
- setElementAttachedOffsets
- setElementCallPropagationEnabled
- setElementCollisionsEnabled
- setElementData
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementModel
- setElementParent
- setElementPosition
- setElementRotation
- setElementVelocity
- setLowLODElement
- getPedContactElement
- getResourceDynamicElementRoot
- getResourceRootElement