setElementBoneRotation
Client-side
Server-side
Shared
Pair: getElementBoneRotation
This function sets the rotation of a specific bone relative to the element. Currently the player and ped element types are accepted.
Note
The updateElementRpHAnim must be called after this function to apply bone rotation.
Tip
- If you want to attach an element to a bone, see pAttach.
- If you're experiencing gimbal lock issues during calculations, use setElementBoneQuaternion.
Syntax
bool setElementBoneRotation ( element theElement, int boneId, float yaw, float pitch, float roll )Required Arguments
- theElement: The element to set the bone rotation on.
- boneId: The ID of the bone to set the rotation of. See Bone IDs.
- yaw: The yaw rotation value.
- pitch: The pitch rotation value.
- roll: The roll rotation value.
Returns
- bool: result
Returns true if the function was successful, false otherwise.
Code Examples
client
This example shows how you can turn a local player into a so-called 'Helicopter'.
local customYaw = 0local shoulders = {22, 32}
setTimer (function () customYaw = customYaw + 20end, 10, 0)
function changeBoneRotation () local yaw, pitch, roll = getElementBoneRotation(localPlayer, 2) -- Get the element's bone rotation setElementBoneRotation(localPlayer, 2, customYaw, pitch, roll) -- Set the elements' bone rotation with custom yaw
for key, value in pairs(shoulders) do setElementBoneRotation(localPlayer, value, 0, 0, 0) -- Update the ped's shoulders rotation end
updateElementRpHAnim(localPlayer) -- Update the ped's bone animationsendaddEventHandler("onClientPedsProcessed", root, changeBoneRotation)See Also
Element Functions
- addElementDataSubscriber
- attachElements
- clearElementVisibleTo
- cloneElement
- createElement
- destroyElement
- detachElements
- getAllElementDataUpdated
- getAttachedElements
- getElementAlpha
- getElementAngularVelocity
- getElementAttachedOffsets
- getElementAttachedTo
- getElementBonePosition
- getElementBoneQuaternionNew
- getElementBoneRotation
- getElementBoundingBox
- getElementByID
- getElementByIndex
- getElementChild
- getElementChildren
- getElementChildrenCount
- getElementCollisionsEnabled
- getElementColShape
- getElementData
- getElementDimension
- getElementDistanceFromCentreOfMassToBaseOfModel
- getElementHealth
- getElementID
- getElementInterior
- getElementLighting
- getElementMatrix
- getElementModel
- getElementParent
- getElementPosition
- getElementRadius
- getElementRotation
- getElementsByType
- getElementsWithinColShape
- getElementsWithinRange
- getElementSyncer
- getElementType
- getElementVelocity
- getElementZoneName
- getLowLODElement
- getRootElement
- hasElementData
- hasElementDataSubscriber
- isElement
- isElementAttached
- isElementCallPropagationEnabled
- isElementCollidableWith
- isElementDoubleSided
- isElementFrozen
- isElementInWater
- isElementLocal
- isElementLowLOD
- isElementOnFireNew
- isElementOnScreen
- isElementStreamable
- isElementStreamedIn
- isElementSyncer
- isElementVisibleTo
- isElementWaitingForGroundToLoad
- isElementWithinColShape
- isElementWithinMarker
- removeElementData
- removeElementDataSubscriber
- setElementAlpha
- setElementAngularVelocity
- setElementAttachedOffsets
- setElementBonePosition
- setElementBoneQuaternionNew
- setElementBoneRotation
- setElementCallPropagationEnabled
- setElementCollidableWith
- setElementCollisionsEnabled
- setElementDataUpdated
- setElementDimension
- setElementDoubleSided
- setElementFrozen
- setElementHealth
- setElementID
- setElementInterior
- setElementLightingNew
- setElementMatrix
- setElementModel
- setElementOnFireNew
- setElementParent
- setElementPosition
- setElementRotation
- setElementStreamable
- setElementSyncer
- setElementVelocity
- setElementVisibleTo
- setLowLODElement
- updateElementRpHAnim
Element Events
- onClientElementColShapeHit
- onClientElementColShapeLeave
- onClientElementDataChange
- onClientElementDestroy
- onClientElementDimensionChange
- onClientElementInteriorChange
- onClientElementModelChange
- onClientElementStreamIn
- onClientElementStreamOut
- onElementClicked
- onElementColShapeHit
- onElementColShapeLeave
- onElementDataChange
- onElementDestroy
- onElementDimensionChange
- onElementInteriorChange
- onElementModelChange
- onElementStartSync
- onElementStopSync
