local entity_position = Entity_GetPosition(entity) -- Move entity forward by 5 along the x axis local new_position = World_Pos( entity_position.x + 5, entity_position.y, entity_position.z ) Entity_SetPosition(entity, new_position)
Position is encoded as a table with
x, y, z entries. Such a table can be created with the
World_Pos(x, y, z) function. The X and Z axes point along the map plane and the Y axis is the up direction.
Entity_GetPosition(entity)to get the position of an entity. The returned object has
x, y, zfields.
Entity_SetPosition(entity, position)to set the position of an entity. The entity will not snap to the position immediately but will interpolate to it smoothly during the frame.
const entityPosition = Entity_GetPosition(entity) // Move entity forward by 5 along the x axis const newPosition = World_Pos( entityPosition.x + 5, entityPosition.y, entityPosition.z ) Entity_SetPosition(entity, newPosition)
Rotation is encoded as a heading vector (ie. the forward direction vector). The vector uses the same type as positions and can also be created with
World_Pos(x, y, z).
Entity_GetHeading(entity)to get the heading of an entity. The returned object has
x, y, zfields.
Entity_SetHeading(entity, heading, bInterpolate)to set the heading of an entity. The entity will rotate immediately or interpolate smoothly depending on whether bInterpolate is
local entity_heading = Entity_GetPosition(entity) print(entity_heading.x, entity_heading.y, entity_heading.z) -- Make the entity point along the X axis local new_heading = World_Pos(1, 0, 0) Entity_SetHeading(entity, new_heading, true)
const entityHeading = Entity_GetHeading(entity) print(entityHeading.x, entityHeading.y, entityHeading.z) // Make the entity point along the X axis const newHeading = World_Pos(1, 0, 0) Entity_SetHeading(entity, newHeading, true)
- Functions for manipulating position and heading also exist for other types of objects (eg.
- As rotation is encoded as a heading vector we can not have roll angle (ie. a rotation around the forward direction)