nearestObject: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(example)
(format, description, syntax)
Line 7: Line 7:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Nearest object of given type to given position within a range of 50 meters. If object ID passed as an argument (as in example 2) the search range is unlimited.
| Returns the nearest object of given type to given position within a sphere. Hardcoded radius is 50 meters. Unlike with [[nearestObjects]], where distance is measured in 2D space, [[nearestObject]] will be closest object in 3D space.<br><br>
If object class type is used, any object derived from the type is found as well (In OFP however, only objects with exactly the type given are found). If object ID passed as an argument (as in example 2) the search range is unlimited.|= Description
____________________________________________________________________________________________
 
| '''nearestObject''' [position, type] |= Syntax
 
|p1= [position, type]: [[Array]] |=
|p2= position:  [[Position3D]] or [[Position2D]] or [[Object]] - position to start search at|=
|p3= type: [[String]] - type of object (see [[typeOf]], [[CfgVehicles|class type]])|=
 
| [[Object]] - Nearest object, [[objNull]] otherwise |= Return value


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
|s2= '''nearestObject''' position |= Syntax
 
|p21= position:  [[Position3D]] or [[Position2D]] or [[Object]] - position to start search at|=
 
|r2= [[Object]] - Nearest object, [[objNull]] otherwise |= Return value
____________________________________________________________________________________________
 
|s3= position '''nearestObject''' type |=
 
|p41= position: [[Position3D]] or [[Position2D]] - position to start search at|=
|p42= type: [[String]] - type of object (see [[typeOf]], [[CfgVehicles|class type]])|=


|p1= filter: [[Array]] - Can be one of the following:<br>
|r3= [[Object]] - Nearest object, [[objNull]] otherwise |=
[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


| [[Object]] - Found object, or [[objNull]] if nothing in range. |= Return value
____________________________________________________________________________________________
____________________________________________________________________________________________


|s2= position '''nearestObject''' filter |=  
|s4= position '''nearestObject''' id |=  


|p21= position: [[Array]] - [[PositionAGL]] or [[Position2D]].|=
|p61= position: [[Position3D]] or [[Position2D]] - position to start search at|=
|p22= filter: [[Number]] or [[String]] - Either ID of object, or [[CfgVehicles|class type]].|=  
|p62= id: [[Number]] - object Visitor id|=  


|r2= [[Object]] - Found object, or [[objNull]] if nothing in range. |=
|r4= [[Object]] - Nearest object, [[objNull]] otherwise |=
____________________________________________________________________________________________
____________________________________________________________________________________________



Revision as of 18:58, 17 February 2016

Hover & click on the images for description

Description

Description:
Returns the nearest object of given type to given position within a sphere. Hardcoded radius is 50 meters. Unlike with nearestObjects, where distance is measured in 2D space, nearestObject will be closest object in 3D space.

If object class type is used, any object derived from the type is found as well (In OFP however, only objects with exactly the type given are found). If object ID passed as an argument (as in example 2) the search range is unlimited.
Groups:
Uncategorised

Syntax 1

Syntax:
nearestObject [position, type]
Parameters:
[position, type]: Array
position: Position3D or Position2D or Object - position to start search at
type: String - type of object (see typeOf, class type)
Return Value:
Object - Nearest object, objNull otherwise

Syntax 2

Syntax:
nearestObject position
Parameters:
position: Position3D or Position2D or Object - position to start search at
Return Value:
Object - Nearest object, objNull otherwise

Syntax 3

Syntax:
position nearestObject type
Parameters:
position: Position3D or Position2D - position to start search at
type: String - type of object (see typeOf, class type)
Return Value:
Object - Nearest object, objNull otherwise

Syntax 4

Syntax:
position nearestObject id
Parameters:
position: Position3D or Position2D - position to start search at
id: Number - object Visitor id
Return Value:
Object - Nearest object, objNull otherwise

Examples

Example 1:
_nObject = nearestObject [2345,6789]; _nObject = nearestObject [player, "StreetLamp"];
Example 2:
Return the object with ID 123456:_nObject = [0,0,0] nearestObject 123456;
Example 3:
_nObject = getPos player nearestObject "StreetLamp";
Example 4:
Return the nearest object with (typeOf _nObject == "#XXXX") -> #mark, #slop, etc. Unlimited search range:_nObject = _position nearestObject -1; Return the nearest object with (typeOf _nObject != ""). Search range is 50m: _nObject = nearestObject _position;
Example 5:
_blood = nearestObject [player, "#slop"]; _step = nearestObject [player, "#mark"]; _track = nearestObject [player, "#track"]; _crater = nearestObject [player, "#crater"];

Additional Information

See also:
nearestObjectsnearObjectsReadynearObjectsobjectFromNetIdnearEntitiesentitiesobject

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