nearestTerrainObjects: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Undo revision 95578 by Icaruk (talk) reverting bad edit)
(sort param)
Line 25: Line 25:
<br>
<br>
Possible type names:<tt>"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"</tt>
Possible type names:<tt>"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"</tt>
<br><br>
Since Arma 3 v1.61.136035 it is possible to switch the sorting algorithm off by providing an extra param, which significantly increases the performance of this command, especially if the serach is performed with large radius.
|= Description
|= Description
____________________________________________________________________________________________
____________________________________________________________________________________________


|'''nearestTerrainObjects''' [position, types, radius]
|'''nearestTerrainObjects''' [position, types, radius, sort]


|p1= position:  [[Object]]  or [[Array]] in format [[PositionAGL]] or [[Position2D]] - where to find objects, center position. |=Parameter 1
|p1= position:  [[Object]]  or [[Array]] in format [[PositionAGL]] or [[Position2D]] - where to find objects, center position. |=Parameter 1
|p2= types: [[Array]] - list of types of the objects to search for. |=Parameter 2
|p2= types: [[Array]] - list of types of the objects to search for. |=Parameter 2
|p3= radius: [[Number]] - range from center position to search for objects. |=Parameter 3
|p3= radius: [[Number]] - range from center position to search for objects. |=Parameter 3
|p3= sort (Optional): [[Boolean]] - Sort objects by distance to the center or not. Default: [[true]] - always sort. (''Available since Arma 3 v1.61.136035'') |=Parameter 3


| [[Array]] - array of terrain objects sorted according to [[distance2D]] |= Return value
| [[Array]] - array of terrain objects sorted according to [[distance2D]] |= Return value
Line 40: Line 43:
|x2= <code>[[nearestTerrainObjects]] <nowiki>[</nowiki>[[player]], ["House"], 200];</code> |= Example 2
|x2= <code>[[nearestTerrainObjects]] <nowiki>[</nowiki>[[player]], ["House"], 200];</code> |= Example 2
|x3= <code>[[nearestTerrainObjects]] <nowiki>[</nowiki>[2716,2949,0], ["Chapel","Fuelstation"], 100];</code> |= Example 2
|x3= <code>[[nearestTerrainObjects]] <nowiki>[</nowiki>[2716,2949,0], ["Chapel","Fuelstation"], 100];</code> |= Example 2
|x4= Return every terrain object in 50 metres radius around player:<code>[[nearestTerrainObjects]] <nowiki>[</nowiki>[[player]], [], 50]</code> |= Example 4
|x4= Return every terrain object in 50 metres radius around player ordered, closest first:<code>[[nearestTerrainObjects]] <nowiki>[</nowiki>[[player]], [], 50]</code> |= Example 4
|x5= Return every terrain object in 50 metres radius around player unordered:<code>[[nearestTerrainObjects]] <nowiki>[</nowiki>[[player]], [], 50, [[false]]]</code> |= Example 5
____________________________________________________________________________________________
____________________________________________________________________________________________



Revision as of 16:13, 15 May 2016

Hover & click on the images for description

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 distance2D 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 an extra param, which significantly increases the performance of this command, especially if the serach is performed with large radius.
Groups:
Uncategorised

Syntax

Syntax:
nearestTerrainObjects [position, types, radius, sort]
Parameters:
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.
sort (Optional): Boolean - Sort objects by distance to the center or not. Default: true - always sort. (Available since Arma 3 v1.61.136035)
Return Value:
Array - array of terrain objects sorted according to distance2D

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

Additional Information

See also:
findNearestEnemyhideObjectnearestBuildingnearestObjectnearObjectsnearestLocationnearEntitiesnearTargetsnearSuppliesnearestLocationWithDubbingnearObjectsReadynearRoads

Notes

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

Notes

Bottom Section