{"name":"nearObjects","operator":null,"title":"nearObjects","type":"command","url":"https://community.bistudio.com/wiki/nearObjects","revid":377428,"updated":"2026-01-02T06:45:43Z","groups":["Object Detection"],"status":"ok","replaced_by":[],"games":[{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma1","name":"Armed Assault","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"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.","syntaxes":[{"syntax":"position nearObjects radius","since":null,"effect":null,"exec":null,"params":[{"name":"position","type":"Position, Position2D or Object","optional":false,"default":null,"description":null,"types":["Position","Position2D","Object"],"since":null,"text":"position: Position, Position2D or Object"},{"name":"radius","type":"Number","optional":false,"default":null,"description":null,"types":["Number"],"since":null,"text":"radius: Number"}],"returns":{"type":"Array of Objects","types":["Array","Object"],"description":null,"text":"Array of Objects"},"form":"binary","operator":null,"left":{"text":"position","types":["Position","Position2D","Object"]},"right":{"text":"radius","types":["Number"]}},{"syntax":"position nearObjects [typeName, radius]","since":null,"effect":null,"exec":null,"params":[{"name":"position","type":"PositionAGL, Position2D or Object","optional":false,"default":null,"description":null,"types":["PositionAGL","Position2D","Object"],"since":null,"text":"position: PositionAGL, Position2D or Object"},{"name":"typeName","type":"String","optional":false,"default":null,"description":null,"types":["String"],"since":null,"text":"typeName: String"},{"name":"radius","type":"Number","optional":false,"default":null,"description":null,"types":["Number"],"since":null,"text":"radius: Number"}],"returns":{"type":"Array of Objects","types":["Array","Object"],"description":null,"text":"Array of Objects"},"form":"binary","operator":null,"left":{"text":"position","types":["PositionAGL","Position2D","Object"]},"right":{"text":"[typeName, radius]","types":["Array"]}}],"examples":[{"text":"```sqf\n_list = position player nearObjects 50;\n```","code":["_list = position player nearObjects 50;"]},{"text":"```sqf\n_list = [_xpos,_ypos] nearObjects [\"House\", 20];\n```","code":["_list = [_xpos,_ypos] nearObjects [\"House\", 20];"]},{"text":"```sqf\n_list = player nearObjects 20;\n```","code":["_list = player nearObjects 20;"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["findNearestEnemy","nearestBuilding","nearestObject","nearestObjects","nearestLocation","nearEntities","nearTargets","nearSupplies","nearestLocationWithDubbing","nearObjectsReady","nearRoads","nearestMines"],"notes":[{"user":"Kronzky","date":"2007-06-30T08:21:00Z","text":"Units in vehicles are not detected via this command."},{"user":"Tankbuster","date":"2011-12-15T23:17:00Z","text":"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)"},{"user":"Tankbuster","date":"2013-01-03T19:59:00Z","text":"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."},{"user":"Cheitan","date":"2017-08-08T16:08:00Z","text":"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."}],"categories":["ArmA: Armed Assault: New Scripting Commands","ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Object Detection","Introduced with Armed Assault version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}