Arma 3 Scripting

Command in Positions

modelToWorld

Also available as Markdown and JSON, or read the original wiki page.

Description

Translates relative position from object model space to world space in PositionAGL format.

This command will take into account vectorUp of the object when calculating relative coordinates. For the PositionASL version of this command, see modelToWorldWorld.

Important

For scaled objects, the relative position will first be multiplied by the object scale.

For example, if the object scale is 2, _obj modelToWorld [0,1,0] will be offset 2 meters from the model center ([0,0,0]).

Syntax

model modelToWorld position

Parameters:

Returns: PositionAGL - translated world position

Examples

Example 1

_aboveAndBehindPlayer = player modelToWorld [0,-1,3];

See also

vectorModelToWorld · modelToWorldVisual · worldToModel · modelToWorldWorld · modelToWorldVisualWorld · selectionPosition

Community notes

Dr_Eyeball

The worldPos parameter appears to be a relative offset to the position of object, so it can often simply be [0,0,0].

Example: to position an object _obj relative to the position of another object _relObj with on offset of _offset, try:

_offset = [_x,_y,_z];
_worldPos = _relObj modelToWorld _offset;
_obj setPos _worldPos;
Hduregger

The z height returned changes dynamically with the height of waves beneath the object, if the object is located over sea. The z height returned by getPosATL and getPosASL does not change like this. This was tested by continuously retrieving the position of a static object, like the cross in the empty/corpses category, placed over sea or land. modelToWorld behaves similar to getPos but it does not give the same result, therefore

_obj modelToWorld [0.0, 0.0, 0.0]

is not the same as

getPos _obj;

.