nearestTerrainObjects: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "_x" to "_x")
m (Text replacement - "v1\.[9-9]{2}\.[0-9]{6}" to "v2.00")
Line 15: Line 15:
Since Arma 3 v1.65.138818 it is possible to switch search and sorting mode between 2D and 3D.
Since Arma 3 v1.65.138818 it is possible to switch search and sorting mode between 2D and 3D.
<br>
<br>
Since Arma 3 v1.99.146404 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>  
<br><br>
<br><br>
<syntaxhighlight lang="cpp"></syntaxhighlight><!---THIS IS HERE TO MAKE SYNTAX HIGHLIGHTING WORK INSIDE THE SPOILER (BLACKMAGIC)--->
<syntaxhighlight lang="cpp"></syntaxhighlight><!---THIS IS HERE TO MAKE SYNTAX HIGHLIGHTING WORK INSIDE THE SPOILER (BLACKMAGIC)--->

Revision as of 10:05, 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.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]
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.