Distance to position3D (array) does not work with Operation Flashpoint, only objects
Armed Assault: position3D (array) and object works
Also available as Markdown and JSON, or read the original wiki page.
Returns a distance in meters between Objects, Positions or Locations.
Important
If positions are supplied as arguments, the coordinates are treated as PositionAGL. If Position2D is supplied, z is assumed 0. If you need distance between two Position3D coordinates, use vectorDistance.
param1 distance param2
Parameters:
param1: Object or PositionAGL or Position2Dparam2: Object or PositionAGL or Position2DReturns: Number - distance in meters or 1e10 if distance cannot be calculated
location1 distance location2
Parameters:
location1: Location or Position or Position2Dlocation2: Location or Position or Position2DReturns: Number - distance in meters or 1e10 if distance cannot be calculated
since arma3 2.18
a distance b
Parameters:
Returns: Number - distance c calculated as c = sqrt(a * a + b * b);
_meters = player distance _object;
_meters = player distance [1,2,3];
_meters = [1,2,3] distance [4,5,6];
_meters = position player distance nearestLocation [position player, "hill"];
distanceSqr · vectorDistance · distance2D
Distance to position3D (array) does not work with Operation Flashpoint, only objects
Armed Assault: position3D (array) and object works
This returns the map distance, not the vector distance, [0,0,0] distance [0,0,1] can be >1 or <1, not exactly 1; unlike the vector math.
If a position in format [x, y, z] is provided for both arguments, distance also checks the z dimension as well. Ie: player distance [0,0,200] will return 200, if the player is at this position at ground/sea level.
When objects are supplied as arguments, distance is calculated from their model center (object modelToWorld [0,0,0]), and not the position returned by getPos/ATL/ASL.
However, this is not relevant for units, as their model center matches their world position.