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 = core.model.create("character")
local position = entity:get_bone_position("Head")

core.engine.print("info", "Bone position:", util.table.unpack(position))
Draw a screen-space marker at a bone's world position
local entity = core.model.create("character")
local bone = "Head"

util.event.on("sandbox:draw", function()
    local position = entity:get_bone_position(bone)
    local screen, distance = core.engine.world_to_screen(position)
    if screen[1] == -1 then return false end

    core.engine.draw_circle(screen, 5, {1, 0, 0, 1})
end)

On this page