nearestObject: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(add. ArmA2 classification)
(merged command variations)
Line 7: Line 7:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Nearest object of given type to given position.
| Nearest object of given type to given position within a range of 50 meters.


For nearestObject pos, pos may be [x, y ,z, "type"] or [object, "type"] or even [x, y, z].
If class types are used in the filter, then in Arma any object derived from the type is found as well. In OFP, only objects with exactly the type given are found.|= Description
____________________________________________________________________________________________
 
| '''nearestObject''' filter |= Syntax


*Before ArmA the funcion matched only objects with exactly the type given.
|p1= filter: [[Array]] - Can be one of the following:<br>
[x,y,z]: Any objects near position<br>
<nowiki>[[</nowiki>x,y,z], "type"]: Objects of class "type" near position [x,y,z]<br>
[object, "type"]: Objects of class "type" near position of "object"<br>
|= Parameter 1


*Since ArmA, any object derived from the type is found as well.|= Description
| [[Object]] - Found object, or [[objNull]] if nothing in range. |= Return value
____________________________________________________________________________________________
____________________________________________________________________________________________


| '''nearestObject''' pos |= Syntax
|s2= position '''nearestObject''' filter |=  


|p1= pos: [[Array]] |= Parameter 1
|p21= position: [[Array]] - [[Position2D]] or [[Position3D]].|=
|p22= filter: [[Number]] or [[String]] - Either ID of object, or [[CfgVehicles|class type]].|=  


| [[Object]] |= Return value
|r2= Found object, or [[objNull]] if nothing in range. |=
____________________________________________________________________________________________
____________________________________________________________________________________________
   
   
|x1= <code>_nObject <nowiki>=</nowiki> nearestObject <nowiki>[</nowiki>[[player]], "StreetLamp"] </code> |= Example 1
|x1= <pre>_nObject = nearestObject [2345,6789]
|x2= <code>_nObject <nowiki>=</nowiki> nearestObject  <nowiki>[</nowiki>[[player]], "Tank"] </code> |= Example 2 (ArmA)
_nObject = nearestObject [player, "StreetLamp"]  
</pre> |= Example 1
|x2= <pre>_nObject = getPos player nearestObject 123456 </pre> |= Example 2
|x3= <pre>_nObject = getPos player nearestObject "StreetLamp" </pre> |= Example 3
____________________________________________________________________________________________
____________________________________________________________________________________________


[[nearestObject type]], [[nearestObjects]], [[nearObjects]], [[nearestObject id]] |= See also
|  [[nearestObjects]], [[nearObjects]] |= See also


}}
}}
Line 35: Line 47:
<dl class="command_description">
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section BEGIN -->
This command can only find objects up to 50 meters away.
 
<!-- Note Section END -->
<!-- Note Section END -->
</dl>
</dl>

Revision as of 18:06, 26 June 2009

Hover & click on the images for description

Description

Description:
Nearest object of given type to given position within a range of 50 meters. If class types are used in the filter, then in Arma any object derived from the type is found as well. In OFP, only objects with exactly the type given are found.
Groups:
Uncategorised

Syntax

Syntax:
nearestObject filter
Parameters:
filter: Array - Can be one of the following:
[x,y,z]: Any objects near position
[[x,y,z], "type"]: Objects of class "type" near position [x,y,z]
[object, "type"]: Objects of class "type" near position of "object"
Return Value:
Object - Found object, or objNull if nothing in range.

Alternative Syntax

Syntax:
position nearestObject filter
Parameters:
position: Array - Position2D or Position3D.
filter: Number or String - Either ID of object, or class type.
Return Value:
Found object, or objNull if nothing in range.

Examples

Example 1:
_nObject = nearestObject [2345,6789]
_nObject = nearestObject [player, "StreetLamp"] 
Example 2:
_nObject = getPos player nearestObject 123456 
Example 3:
_nObject = getPos player nearestObject "StreetLamp" 

Additional Information

See also:
nearestObjectsnearObjects

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

Notes

Bottom Section