Vital.sandbox
Model

self:get_bone_position

Shared

Retrieves the current position of a skeleton bone in 3D world-space


Syntax

local position = self:get_bone_position(bone)

Parameters

TypeNameDescription
stringboneName of the bone to retrieve the position of

Returns

TypeNameDescription
vector3position3D world-space position of the bone as {x, y, z}

Examples

Get the world-space position of a bone
local entity = model.create("character")
local position = entity:get_bone_position("Head")

engine.print("info", "Bone position:", position[1], position[2], position[3])
Draw a screen-space marker at a bone's world position
local entity = model.create("character")
local bone = "Head"

network:fetch("vital.sandbox:draw", true):on(function()
    local position = entity:get_bone_position(bone)
    local screen, distance = engine.world_to_screen(position)
    if screen[1] ~= -1 then
        engine.draw_circle(screen, 5, {1, 0, 0, 1})
    end
end)

On this page