natiny.entity.get_rotation

Lua
natiny.entity.get_rotation(node [, space]) -> rx, ry, rz

Returns the orientation of a node in degrees, as three separate numbers.

Parameters

Name Type Default Description
node number Entity handle (e.g. model, pivot, body, sound source or camera)
space integer natiny.entity.SPACE_WORLD natiny.entity.SPACE_LOCAL or natiny.entity.SPACE_WORLD

Returns

Type Description
number Rotation around X, in degrees
number Rotation around Y, in degrees
number Rotation around Z, in degrees

Example

Lua
local _, yaw = natiny.entity.get_rotation(turret, natiny.entity.SPACE_WORLD)
natiny.entity.set_rotation(barrel, natiny.entity.SPACE_WORLD, 0, yaw, 0)

Notes

  • Degrees, the same units natiny.entity.set_rotation and natiny.entity.rotate take.
  • The angles are applied in Y-X-Z order - yaw, then pitch, then roll - which is the order set_rotation reads them in.
  • SPACE_LOCAL returns the stored parent-relative angles, which is exactly what set_rotation wrote in the same space. SPACE_WORLD composes them with every parent's and decomposes the result.
  • A world read answers with one triple naming that orientation, not necessarily the triple that was written: past ±90° of pitch, and at gimbal lock, a different triple describes the same rotation. Compare orientations, not the numbers.
  • A handle that is not a live node returns 0, 0, 0.