nearestTerrainObjects: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "v1\.61\.[0-9]{6}" to "v1.62")
m (Text replacement - "v1\.65\.[0-9]{6}" to "v1.66")
Line 13: Line 13:
Since Arma 3 v1.62 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.62 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.
<br>
<br>
Since Arma 3 v1.65.138818 it is possible to switch search and sorting mode between 2D and 3D.
Since Arma 3 v1.66 it is possible to switch search and sorting mode between 2D and 3D.
<br>
<br>
Since Arma 3 v2.00 this command also returns missing roads: <tt>"ROAD", "MAIN ROAD", "TRACK", "TRAIL"</tt>  
Since Arma 3 v2.00 this command also returns missing roads: <tt>"ROAD", "MAIN ROAD", "TRACK", "TRAIL"</tt>  
Line 285: Line 285:
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dd class="note">
<dd class="note">
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.  
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.  
</dd>
</dd>



Revision as of 10:21, 3 April 2021

Hover & click on the images for description

Description

Description:
Description needed
Groups:
Object Detection

Syntax

Syntax:
Syntax needed
Parameters:
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
sort: Boolean - (Optional, default true) sort objects by distance to the center or not Template:Since
2Dmode: Boolean - (Optional, default false) the object search and sorting mode: true - 2D, false - 3D Template:Since
Return Value:
Return value needed

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];
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:
nearestObjectsfindNearestEnemyhideObjectnearestBuildingnearestObjectnearObjectsnearestLocationnearEntitiesnearTargetsnearSuppliesnearestLocationWithDubbingnearObjectsReadynearRoadsroadsConnectedToroadAtisOnRoadgetRoadInfo

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


Posted on October 31, 2016 - 00:20 (UTC)
Killzone Kid
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 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]
Posted on June 7, 2020 - 14:16 (UTC)
killzone_kid
Large bridges are map type "ROAD". Small foot bridges are not roads and not included into road net.