From Bohemia Interactive Community
Jump to navigation Jump to search
Hover & click on the images for description


Returns a list of nearest terrain objects of the given types to the given position or object, within the specified distance. If more than one object is found they will be ordered according to 3D distance to the object (i.e. the closest one will be first in the array). In contrast to nearestObjects this command returns terrain placed objects like trees, rocks and buildings which don't necessarily need an associated config class.

Possible type names:
  • "BUNKER"
  • "BUSH"
  • "CHAPEL"
  • "CHURCH"
  • "CROSS"
  • "FENCE"
  • "FOREST"
  • "HIDE"
  • "HOUSE"
  • "QUAY"
  • "ROAD"
  • "ROCK"
  • "ROCKS"
  • "RUIN"
  • "STACK"
  • "TRACK"
  • "TRAIL"
  • "TREE"
  • "WALL"

The names are / The filter is based on the named property map - not on the named property class or any config definition!

Terrain object counts

Object Detection


nearestTerrainObjects [position, types, radius, sort, 2Dmode]
position: Object, PositionAGL or Position2D - where to find objects, center position
types: Array - list of case-insensitive types of the objects to search for. [] to search without filters
radius: Number - range from center position to search for objects
since Arma 3 logo black.png1.62
sort: Boolean - (Optional, default true) sort objects by distance to the center or not - setting to false greatly improves performance
since Arma 3 logo black.png1.66
2Dmode: Boolean - (Optional, default false) the object search and sorting mode: true - 2D, false - 3D
Return Value:
Array - array of terrain objects. Before Arma 3 v2.00 this command did not return roads of type "ROAD", "MAIN ROAD", "TRACK", "TRAIL"


Example 1:
nearestTerrainObjects [player, ["Tree", "Bush"], 200];
Example 2:
nearestTerrainObjects [player, ["House"], 200];
Example 3:
nearestTerrainObjects [[2716, 2949, 0], ["Chapel", "Fuelstation"], 100];
Example 4:
Return every terrain object in 50 metres radius around player sorted, closest first:
Example 5:
Return every terrain object in 50 metres radius around player unsorted:
Example 6:
Hide all terrain objects nearestTerrainObjects could find:
if (isServer) then { private _allTerrainObjects = nearestTerrainObjects [ [worldSize / 2, worldSize / 2], [], worldSize * sqrt 2 / 2, false ]; { _x hideObjectGlobal true } forEach _allTerrainObjects; };

Additional Information

See also:
nearestObjects findNearestEnemy hideObject nearestBuilding nearestObject nearObjects nearestLocation nearEntities nearTargets nearSupplies nearestLocationWithDubbing nearObjectsReady nearRoads roadsConnectedTo roadAt isOnRoad getRoadInfo nearestMines


Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Posted on Oct 31, 2016 - 00:20 (UTC)
Since Arma 3 v1.66 the default sorting is done according to 3D distance not distance2D as before. This is an attempt to correct some very old bug in implementation.
Posted on Dec 28, 2016 - 20:21 (UTC)
Be aware that some terrain objects types might be tricky to be found, such as terrain rocks and boulders which are not considered to be "ROCKS" or "ROCK", but "HIDE". Example:
nearestTerrainObjects [player, ["HIDE"], 20]; // [939688: bluntstone_01.p3d,939691: garbagebags_f.p3d,939671: wreck_car_f.p3d,939692: junkpile_f.p3d]
Posted on Jun 07, 2020 - 14:16 (UTC)
Large bridges are map type "ROAD". Small foot bridges are not roads and not included into road net.