Arma 3 Scripting

nearObjects

  • Arma 3 v0.50
  • First in Armed Assault v1.00

Command · Markdown · JSON · original wiki page

Description

Find objects (Units, Vehicles, Dead, Map Objects) in a sphere with given radius. The first object in the returned array is not necessarily the closest one. If you need returned objects to be sorted by distance, use nearestObjects. If typeName is given, only objects of given type (or its subtype) are listed.

Syntax

Syntax 1

position nearObjects radius

Parameters:

Returns: Array of Objects

Syntax 2

position nearObjects [typeName, radius]

Parameters:

Returns: Array of Objects

Examples

Example 1

_list = position player nearObjects 50;

Example 2

_list = [_xpos,_ypos] nearObjects ["House", 20];

Example 3

_list = player nearObjects 20;

See also

findNearestEnemy · nearestBuilding · nearestObject · nearestObjects · nearestLocation · nearEntities · nearTargets · nearSupplies · nearestLocationWithDubbing · nearObjectsReady · nearRoads · nearestMines

Community notes

Kronzky

Units in vehicles are not detected via this command.

Tankbuster

In the second syntax, you can't omit the typeName parameter. It's required and you'll get an error if you don't supply it. Use "All" as an alternative to leaving it out. (CO 1.59)

Tankbuster

If you use the first syntax, it will return objects many more objects such as pollen, honeybees and crucially, triggers. Triggers will show in the returned array as "no shape" but you can use typeOf to get the classname, which will give "EmptyDetector". This will not return objects that don't have classnames such as plants, stones and some map objects like vehicle wrecks. nearestObjects will find objects without classnames.

Cheitan

The syntax 2 means that the command will include all types which inherit from the given type. As an example, when using "Helipad_Base_F", the command will detect all types of helipads (Land_HelipadSquare_F, Land_HelipadCircle_F, Land_HelipadEmpty_F, etc) in the given radius.