setElementBoneQuaternion | Multi Theft Auto: Wiki Skip to content

setElementBoneQuaternion

Client-side
Server-side
Shared

Pair: getElementBoneQuaternion

Added in 1.6.0 r22741

This function determines how a particular bone rotates in relation to the element. This can be a player or ped.

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

  • bool: result

Returns true if the set was successful, otherwise returns false.

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 = 1
local playerBoneX, playerBoneY, playerBoneZ = 0.577, 0.577, 0.577
local playerBoneW = 0
addEventHandler("onClientPedsProcessed", root, function()
setElementBoneQuaternion(localPlayer, playerBone, playerBoneX, playerBoneY, playerBoneZ, playerBoneW)
updateElementRpHAnim(localPlayer)
end)

See Also

Element Functions