setElementBoneQuaternion
Client-side
Server-side
Shared
Pair: getElementBoneQuaternion
Added in 1.6.0 r22741
Note
If you want to apply the rotation, updateElementRpHAnim must be called after this function.
Tip
- The use of quaternions are more effective and do not generate issues like gimbal lock that might arise with Euler angles, so they are a preferable choice for rotation.
- If you want to attach an element to a bone, see pAttach.
Syntax
bool setElementBoneQuaternion ( element ped, int bone, float x, float y, float z, float w )Required arguments
- ped: The element on which the bone's rotation will be set.
- bone: The ID of the bone to set the quaternion of. See Bone IDs.
- x: The quaternion's coefficient of the 𝑖 component, representing rotation around the x-axis.
- y: The quaternion's coefficient of the 𝑗 component, representing rotation around the y-axis.
- z: The quaternion's coefficient of the 𝑘 component, representing rotation around the z-axis.
- w: The real part of the quaternion, which is linked to the angle of rotation.
Returns
Returns true if the set was successful, otherwise returns false.
- bool: result
Code Examples
client
This example rotates the player's pelvis 180 degrees around an arbitrary axis. The use of updateElementRpHAnim is necessary here as it applies the rotation.
local playerBone = 1local playerBoneX, playerBoneY, playerBoneZ = 0.577, 0.577, 0.577local playerBoneW = 0
addEventHandler("onClientPedsProcessed", root, function() setElementBoneQuaternion(localPlayer, playerBone, playerBoneX, playerBoneY, playerBoneZ, playerBoneW) updateElementRpHAnim(localPlayer)end)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
 showing the six cycles of multiplication by <span style="color:red;">i</span>, <span style="color:green;">j</span> and <span style="color:blue;">k</span>.](/_astro/setElementBoneQuaternion.DxI1OPVK_Z1gwpBh.webp)