Page tree
Skip to end of metadata
Go to start of metadata

Introduced in



Description:Returns a list of nearest objects of the given types to the given position or object, within the specified distance.

If more than one object is found, they are ordered according to their distance (the closest one is first in the array).

The following special class types can be used, to find some objects that cannot be searched for by their class names:

  • [] (empty array): All objects (including environmental ones, such as bugs, as well as unclassed map objects, such as buildings and vegetation).
  • "#crater": Craters created in game (using grenades, IEDs, and so on).
  • "#destructioneffects: Fire and smoke effects created by destroyed objects.
  • "#explosion: Detonations caused by, for example, grenades or IEDs.
  • "#lightpoint": Other Objects - Lights.
  • "#laserpoint": Visible IR Laser.
  • "#mark": Marks left on the ground (for example, tire tracks and foot steps).
  • "#particlesource": Any particle effects created by either the engine (for example, destruction effects) or if a "#particlesource" is created, using createVehicle.
  • "#smokesource": Smoke source.
  • "#crateronvehicle": Damage craters on vehicles.
  • "#smoke": Smoke.
  • "#dynamicsound": Dynamic sound sources.
  • "#objectdestructed": Destroyed object.
  • "#animator": Animator for entities without simulation.
  • "#slop": Slop of blood.
  • "#track": Vehicle tracks.
  • "#thunderbolt": Thunderbolt.
  • "#soundonvehicle": For example, sounds created with the say command.
  • "#wake": Ship wakes.


Syntax:nearestObjects [center, types, radius]
  • center: PositionAGL or Object - Center position from which to check.
  • types: Array - List of object class names to search. Class names are strings found in CfgVehicles, and work hierarchically (searching for a base class finds any matching sub-classes).
  • radius: Number - Range from center position to search.
Return Value:Array


nearestObjects [player, ["Car","Tank"], 200]
nearestObjects [player, ["house"], 200]
nearestObjects [[2716,2949,0], ["Car","Truck"], 100]

Additional Information

See also: nearestObject, nearObjects, nearEntities