natiny_entity_get_position

C
void natiny_entity_get_position(NatinyEntity node, uint32_t space, float* x, float* y, float* z);

Writes the position of a node in the given coordinate space into three output parameters.

Parameters

Name Type Description
node NatinyEntity Entity handle
space uint32_t NATINY_SPACE_LOCAL or NATINY_SPACE_WORLD
x float* Receives position X; may be NULL
y float* Receives position Y; may be NULL
z float* Receives position Z; may be NULL

Example

C
float x, y, z;
natiny_entity_get_position(player, NATINY_SPACE_WORLD, &x, &y, &z);
natiny_entity_set_position(camera, NATINY_SPACE_WORLD, x, y + 1.7f, z);

Notes

  • NATINY_SPACE_LOCAL returns the stored parent-relative position, which is exactly what natiny_entity_set_position wrote in the same space. NATINY_SPACE_WORLD returns the absolute position the parent chain places the node at.
  • The world position is read from the node's world matrix after the parent chain is brought up to date, so it already accounts for moves made earlier in the same frame.
  • For a body, the world position is where the last physics tick left it, or the interpolated position when natiny_physics_set_interpolation is enabled for that body.
  • A handle that is not a live node writes 0 to every non-NULL output.