---
name: "nearTargets"
type: command
status: ok
groups: ["Object Detection"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/nearTargets
revid: 377595
updated: 2026-01-02T07:00:21Z
---

# nearTargets

*Command · Object Detection · Arma 3 v0.50 · introduced in Armed Assault v1.07*

## Description

Returns a list of targets within the defined range. "Targets" are not restricted to enemy units.

## Syntax

```sqf
unit nearTargets range
```

**Parameters:**

- `unit`: [Object](../topics/Object.md)
- `range`: [Number](../topics/Number.md)

**Returns:** [Array](../topics/Array.md) of [Array](../topics/Array.md)s in format [position, type, side, subjectiveCost, object, positionAccuracy]:
- position: [Position3D](../topics/Position.md#introduction) - perceived position including judgment and memory errors
- type: [String](../topics/String.md) - perceived, gives only what was recognized
- side: [Side](../topics/Side.md) - perceived side
- subjectiveCost: [Number](../topics/Number.md) - positive for enemies, more positive for more important or more dangerous enemies
- object: [Object](../topics/Object.md) object type, can be used to get more information if needed
- positionAccuracy: [Number](../topics/Number.md) - assumed accuracy of the perceived position

## Examples

### Example 1

```sqf
player nearTargets 100;
// can return e.g
/*
    [
        [[2555.33,2535.33,1.32708],"SoldierEB",EAST,214222,EAST 1-1-A:1],
        [[2550.39,2482.5,1.32696],"SoldierWB",WEST,0,WEST 1-1-A:2]
    ]
*/
```

## See also

[targets](../commands/targets.md) · [targetsQuery](../commands/targetsQuery.md) · [targetsAggregate](../commands/targetsAggregate.md) · [targetKnowledge](../commands/targetKnowledge.md) · [knowsAbout](../commands/knowsAbout.md) · [reveal](../commands/reveal.md) · [forgetTarget](../commands/forgetTarget.md) · [setTargetAge](../commands/setTargetAge.md) · [getHideFrom](../commands/getHideFrom.md) · [findNearestEnemy](../commands/findNearestEnemy.md) · [nearestBuilding](../commands/nearestBuilding.md) · [nearestObject](../commands/nearestObject.md) · [nearestObjects](../commands/nearestObjects.md) · [nearObjects](../commands/nearObjects.md) · [nearestLocation](../commands/nearestLocation.md) · [nearEntities](../commands/nearEntities.md) · [nearSupplies](../commands/nearSupplies.md) · [nearestLocationWithDubbing](../commands/nearestLocationWithDubbing.md) · [nearObjectsReady](../commands/nearObjectsReady.md) · [nearRoads](../commands/nearRoads.md) · [nearestMines](../commands/nearestMines.md)

## Community notes

**mrcurry** — 2011-02-17

A subjective cost greater than 0 does not necessarily mean the target is an enemy unit. **Any** unit, that have yet to be identified by the unit, have a small positive cost in the range 0 to 1.

---

**.kju** — 2012-01-15

The quality/detail level of the info depends on the [knowsAbout](../commands/knowsAbout.md) value of the sourceUnit about the targetUnit:

- For infantry:
  - ] 0  , 1.5 [ - side unknown, some position offset, identified as SoldierWB
  - [ 1.5, 1.6 [ - side identified, subjective cost set
  - [ 1.6, 2   [ - type identified better (USMC_Soldier_Base)
  - [ 2  , 3.6 [ - type identified precisely (USMC_Soldier)
  - [ 3.6, 4   ] - position identified precisely

The values seems closely linked to the accuracy value of the given targetUnit class and its parents up in the config tree:
- 0			class CAManBase : Man
- 1.6		class SoldierWB : CAManBase
- 2			class USMC_Soldier_Base : SoldierWB
- 3.9		class USMC_Soldier : USMC_Soldier_Base

- For tanks:
  - ] 0   , 0.03 [ - side unknown, some position offset, identified as LandVehicle
  - [ 0.03, 0.13 [ - type identified better (Tank)
  - [ 0.13, 0.3  [ - type identified better (M1A1)
  - [ 0.3 , 1.5  [ - side identified, subjective cost set
  - [ 1.5 , 3.6  [ - side identified precisely (CIV), subjective cost adjusted
  - [ 3.6 , 4    ] - position identified precisely

The values seems closely linked to the accuracy value of the given targetUnit class and its parents up in the config tree:
- 0		class All
- class AllVehicles : All
  - 0.0005		class Land : AllVehicles
  - 0.02		class LandVehicle : Land
  - 0.12		class Tank : LandVehicle
  - 0.25		class M1A1 : Tank

---

**.kju** — 2012-01-17

- When an unit dies, it is nearTargets array gets emptied after some seconds.
- When an unit dies, its reference will get removed from other units nearTargets' arrays immediately.
- A target will be removed from the array after about 360 seconds without contact.

---

**.kju** — 2012-01-21

Position accuracy seems to be a radius in meters from the perceived position.

<sub>Source: [BI Community Wiki — nearTargets](https://community.bistudio.com/wiki/nearTargets) (revision 377595).</sub>
