ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Client functions
  3. getPedBoneMatrix

Function

getPedBoneMatrix

ClientPedsTrilogy Hub only

Returns a ped bone's 4x4 matrix for this frame, in the same layout as getElementMatrix: row 1 = the bone's X axis, 2 = Y axis, 3 = Z axis, 4 = position. These are the same axes in which attachElementToBone applies its offset and rotation, so the attach point is position + X*dx + Y*dy + Z*dz. It is computed straight from the bone rotation in the engine, without Euler angles, so it keeps its precision at 90° turns.

Syntax

table getPedBoneMatrix(ped thePed, int bone)

Arguments

thePedped
The ped (streamed in).
boneint
Bone number (getBoneIDs).

Returns

The matrix { {xx,xy,xz,0}, {yx,yy,yz,0}, {zx,zy,zz,0}, {x,y,z,1} } or false.

Example

addEventHandler("onClientPedsProcessed", root, function()
    local m = getPedBoneMatrix(localPlayer, 25) -- prawa dłoń
    if not m then return end
    -- punkt 20 cm wzdłuż osi X dłoni
    local x, y, z = m[4][1] + m[1][1] * 0.2, m[4][2] + m[1][2] * 0.2, m[4][3] + m[1][3] * 0.2
    dxDrawLine3D(m[4][1], m[4][2], m[4][3], x, y, z, tocolor(255, 0, 0), 2)
end)

Notes

The freshest bone positions are in onClientPedsProcessed (after this frame's animation update).

See also