natiny.entity.get_position
Lua
natiny.entity.get_position(node [, space]) -> x, y, z
Returns the position of a node in the given coordinate space, as three
separate numbers.
Parameters
| Name |
Type |
Default |
Description |
node |
number |
|
Entity handle (e.g. model, body, sound source or camera) |
space |
integer |
natiny.entity.SPACE_WORLD |
natiny.entity.SPACE_LOCAL or natiny.entity.SPACE_WORLD |
Returns
| Type |
Description |
number |
Position X |
number |
Position Y |
number |
Position Z |
Example
Lua
local x, y, z = natiny.entity.get_position(player, natiny.entity.SPACE_WORLD)
natiny.entity.set_position(camera, natiny.entity.SPACE_WORLD, x, y + 1.7, z)
Notes
SPACE_LOCAL returns the stored parent-relative position, which is exactly
what natiny.entity.set_position wrote in the same space.
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 returns
0, 0, 0.