- Documentation
- Shared functions
- getPedBonePosition
Function
getPedBonePosition
Returns the world position of a chosen skeleton bone of a ped, such as the head or a hand. On the client the position is exact and follows the animation (the bone is read from the game). The server does not know the ped's pose, so it returns an approximation: a fixed bone offset of a standing ped, rotated to match its heading. Bone numbers are the ones from getBoneIDs (e.g. 8 head, 25 right hand, 35 left hand); on the client a game bone index also works.
Syntax
float, float, float getPedBonePosition(ped ped, int bone)Arguments
pedped- A player or an NPC.
boneint- Bone number: 1-2 pelvis, 3 spine, 4 upper torso, 5 neck, 6-8 head (8 = head centre), 21-26 right arm (22 shoulder, 23 elbow, 24 wrist, 25 hand), 31-36 left arm (35 = hand), 41-44 left leg (44 = foot), 51-54 right leg (54 = foot). On the client a game bone index also works.
Returns
The bone's x, y, z coordinates, or false.
Example
addEventHandler("onClientRender", root, function()
local x, y, z = getPedBonePosition(localPlayer, 8)
if x then
local sx, sy = getScreenFromWorldPosition(x, y, z + 0.3)
if sx then dxDrawText("Ja", sx, sy) end
end
end)
See also
getPedBoneRotationReturns the world rotation of a chosen skeleton bone of a ped, in degrees, exactly as it looks in the current animation frame. Works for peds visible in this game. Useful for attaching objects to a hand or the head so they rotate with it.getPedBoneTransformReturns both the position and rotation of a ped's bone at once (x, y, z, rx, ry, rz), which is faster than callinggetPedBonePositionandgetPedBoneRotationseparately every frame. Values come from the current animation frame in this game.getBoneNameReturns the English name of the bone with the given number, e.g. 8 →"Head", 25 →"RightHand", 2 →"Pelvis". Returnsfalsewhen the number does not exist.