nearObjects: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Fixed (and slightly clarified) notes)
 
(69 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Category:Scripting Commands|NEAROBJECTS]]
{{RV|type=command
[[Category:Scripting Commands ArmA|NEAROBJECTS]]
[[Category:Command_Group:_Object_Information|{{uc:{{PAGENAME}}}}]]


{{Command|= Comments
|game1= arma1
____________________________________________________________________________________________
|version1= 1.00


| arma |= Game name
|game2= arma2
|version2= 1.00


|1.00|= Game version
|game3= arma2oa
____________________________________________________________________________________________
|version3= 1.50


| Find 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. |= Description
|game4= tkoh
____________________________________________________________________________________________
|version4= 1.00


| position '''nearObjects''' radius |= Syntax
|game5= arma3
|version5= 0.50


|p1= position: [[Position]], [[Position2D]] or [[Object]] |= Parameter 1
|gr1= Object Detection
|p2= radius: [[Number]] |= Parameter 2
| [[Array]]  |= RETURNVALUE


|s2= position '''nearObjects''' [typeName, radius]  |= Syntax
|descr= 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.
|p21= position: [[PositionAGL]], [[Position2D]] or [[Object]]  |= PARAMETER1
|p22= [typeName, radius]: [[Array]] |= PARAMETER2
|p23= typeName: [[String]] |= PARAMETER3
|p24= radius: [[Number]] |= PARAMETER4


|r2= [[Array]] |= Return value
|s1= position [[nearObjects]] radius
__________________________________________________________________________________________
 
|x1= <code>_list = [[position]] [[player]] [[nearObjects]] 50;</code> |= Example 1


|x2= <code>_list = [_xpos,_ypos] [[nearObjects]] ["House", 20];</code> |= Example 2
|p1= position: [[Position]], [[Position#Introduction|Position2D]] or [[Object]]


|x3= <code>_list = [[player]] [[nearObjects]] 20;</code> |= Example 3
|p2= radius: [[Number]]
____________________________________________________________________________________________


| [[findNearestEnemy]], [[nearestBuilding]], [[nearestObject]], [[nearestObjects]], [[nearestLocation]], [[nearEntities]], [[nearTargets]], [[nearSupplies]], [[nearestLocationWithDubbing]], [[nearObjectsReady]], [[nearRoads]] |= See also
|r1= [[Array]]


|s2= position [[nearObjects]] [typeName, radius]


|p21= position: [[Array]] format [[Position#PositionAGL|PositionAGL]], [[Position#Introduction|Position2D]] or [[Object]]


|p22= typeName: [[String]]
|p23= radius: [[Number]]
|r2= [[Array]]
|x1= <sqf>_list = position player nearObjects 50;</sqf>
|x2= <sqf>_list = [_xpos,_ypos] nearObjects ["House", 20];</sqf>
|x3= <sqf>_list = player nearObjects 20;</sqf>
|seealso= [[findNearestEnemy]] [[nearestBuilding]] [[nearestObject]] [[nearestObjects]] [[nearestLocation]] [[nearEntities]] [[nearTargets]] [[nearSupplies]] [[nearestLocationWithDubbing]] [[nearObjectsReady]] [[nearRoads]] [[nearestMines]]
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= Kronzky
<!-- Note Section BEGIN -->
|timestamp= 20070630082100
<dd class="notedate">Posted on June 30, 2007 - 08:21
|text= Units in vehicles are not detected via this command.
<dt class="note">'''[[User:Kronzky|Kronzky]]'''<dd class="note">
}}
Units in vehicles are not detected via this command.
<dd class="notedate">Posted on December 15, 2011 - 23:17
<dt class="note">'''[[User:Tankbuster|Tankbuster]]'''<dd class="note">
In the second example, 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)
<dd class="notedate">Posted on January 3, 2013 - 19:59
<dt class="note">'''[[User:Tankbuster|Tankbuster]]'''<dd class="note">
If you use the first example, 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.
<!-- Note Section END -->
</dl>


<h3 style="display:none">Bottom Section</h3>
{{Note
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
|user= Tankbuster
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
|timestamp= 20111215231700
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
|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)
}}


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= Tankbuster
<dd class="notedate">Posted on August 8, 2017 - 16:08 (UTC)</dd>
|timestamp= 20130103195900
<dt class="note">[[User:Cheitan|Cheitan]]</dt>
|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.
<dd class="note">
}}
The example 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.
 
</dd>
{{Note
</dl>
|user= Cheitan
<!-- DISCONTINUE Notes -->
|timestamp= 20170808160800
|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.
}}

Latest revision as of 20:27, 8 September 2022

Hover & click on the images for description

Description

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.
Groups:
Object Detection

Syntax

Syntax:
position nearObjects radius
Parameters:
position: Position, Position2D or Object
radius: Number
Return Value:
Array

Alternative Syntax

Syntax:
position nearObjects [typeName, radius]
Parameters:
position: Array format PositionAGL, Position2D or Object
typeName: String
radius: Number
Return Value:
Array

Examples

Example 1:
_list = position player nearObjects 50;
Example 2:
_list = [_xpos,_ypos] nearObjects ["House", 20];
Example 3:
_list = player nearObjects 20;

Additional Information

See also:
findNearestEnemy nearestBuilding nearestObject nearestObjects nearestLocation nearEntities nearTargets nearSupplies nearestLocationWithDubbing nearObjectsReady nearRoads nearestMines

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
Kronzky - c
Posted on Jun 30, 2007 - 08:21 (UTC)
Units in vehicles are not detected via this command.
Tankbuster - c
Posted on Dec 15, 2011 - 23:17 (UTC)
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 - c
Posted on Jan 03, 2013 - 19:59 (UTC)
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 - c
Posted on Aug 08, 2017 - 16:08 (UTC)
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.