nearestTerrainObjects

From Bohemia Interactive Community
Jump to: navigation, search
Introduced with Arma 3 version 1.54
  

Click on the images for descriptions

Introduced in

Game:
Arma 3
Version:
1.54

Description

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.

position can use the format: [[x,y,z], ["Type",...], radius] or [object, ["Type",...], radius] To use it without any type filter: [object or position, [], radius]

Possible type names:"TREE", "SMALL TREE", "BUSH", "BUILDING", "HOUSE", "FOREST BORDER", "FOREST TRIANGLE", "FOREST SQUARE", "CHURCH", "CHAPEL", "CROSS", "ROCK", "BUNKER", "FORTRESS", "FOUNTAIN", "VIEW-TOWER", "LIGHTHOUSE", "QUAY", "FUELSTATION", "HOSPITAL", "FENCE", "WALL", "HIDE", "BUSSTOP", "ROAD", "FOREST", "TRANSMITTER", "STACK", "RUIN", "TOURISM", "WATERTOWER", "TRACK", "MAIN ROAD", "ROCKS", "POWER LINES", "RAILWAY", "POWERSOLAR", "POWERWAVE", "POWERWIND", "SHIPWRECK", "TRAIL"

Since Arma 3 v1.61.136035 it is possible to switch the sorting algorithm off by providing optional param, which significantly increases the performance of this command, especially if the search is performed with large radius.

Since Arma 3 v1.65.138818 it is possible to switch search and sorting mode between 2D and 3D

Syntax

Syntax:
nearestTerrainObjects [position, types, radius, sort, 2Dmode]
Parameters:
[position, types, radius, sort, 2Dmode]: Array
position: Object or Array in format PositionAGL or Position2D - where to find objects, center position.
types: Array - list of types of the objects to search for.
radius: Number - range from center position to search for objects.
sort (Optional): Boolean - Sort objects by distance to the center or not. Default: true - always sort. (Available since Arma 3 v1.61.136035)
2Dmode (Optional): Boolean - The object search and sorting mode: true - 2D, false - 3D. Default: false - 3D (Available since Arma 3 v1.65.138818)
Return Value:
Array - array of terrain objects

Examples

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:nearestTerrainObjects [player, [], 50]
Example 5:
Return every terrain object in 50 metres radius around player unsorted:nearestTerrainObjects [player, [], 50, false]

Additional Information

Multiplayer:
-
See also:
nearestObjectsfindNearestEnemyhideObjectnearestBuildingnearestObjectnearObjectsnearestLocationnearEntitiesnearTargetsnearSuppliesnearestLocationWithDubbingnearObjectsReadynearRoads

Notes

Only post proven facts here. Report bugs on the feedback tracker. Use the talk page or the forums for discussions.
Add New Note | How To

Notes

Bottom Section

Posted on October 31, 2016 - 00:20 (UTC)
Killzone Kid
Since Arma 3 v1.65.138818 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 December 28, 2016 - 20:21 (UTC)
Demellion
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]