natiny.entity.get_parent

Lua
natiny.entity.get_parent(node) -> parent

Returns the node this one hangs off, or 0 when it sits at the root.

Parameters

Name Type Description
node number Entity handle (e.g. model, pivot, body, sound source or camera)

Returns

Type Description
number Parent entity handle, or 0 when the node has no parent

Example

Lua
local root = hand
while natiny.entity.get_parent(root) ~= 0 do
    root = natiny.entity.get_parent(root)
end

Notes

  • 0 is the same value natiny.entity.set_parent takes to detach a node, so a value read here can be written straight back.
  • A parent that has since been destroyed is reported as 0. That is what the transform already does with it: a released slot is treated as no parent, and the child's local transform is its world one.
  • A handle that is not a live node returns 0.