findEmptyPosition: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(moving objects are ignored, made pretty)
Line 7: Line 7:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Searches for an empty position around a center location.
| Searches for an empty position around specified position. The search starts looking for an empty position at a minimum distance of [minDistance] from the [center] and looks as far away as [maxDistance]. If a [vehicleType] parameter is specified, then the search will look for an empty positions that is big enough to hold that vehicle type. If an empty position isn't found, an empty array is returned.


The search starts looking for an empty position at a minimum distance of [radius] from the [center] and looks as far away as [maxDistance].
This command ignores moving objects present within search area. |= Description
 
If a [vehicleType] parameter is specified, then the search will look for empty positions that are big enough to hold that vehicle type.
 
If an empty position isn't found, an empty array is returned.  |= Description
____________________________________________________________________________________________
____________________________________________________________________________________________


| center '''findEmptyPosition''' [radius,maxDistance] or [radius,maxDistance,vehicleType] |= Syntax
| center '''findEmptyPosition''' [minDistance, maxDistance] or [minDistance, maxDistance, vehicleType] |= Syntax
 
|p1= center: [[Array]] -  |= PARAMETER1


|p2= [radius,maxDistance,vehicleType]: Array -  |= PARAMETER2
|p1= center: [[Array]] - Search area center position. Accepts [[Position2D]], [[Position3D]], [[PositionATL]] or [[PositionASL]] |= PARAMETER1


|p3= |= PARAMETER3
|p2= [minDistance, maxDistance, vehicleType]: [[Array]] |= PARAMETER2


| [[Array]] |= RETURNVALUE
|p3= minDistance: [[Number]] - Start searching no closer than minDistance from the center |= PARAMETER3
|p4= maxDistance: [[Number]] - Stop searching no further than maxDistance from the center |= PARAMETER4
|p5= vehicleType: [[String]] - Class name of a vehicle to accommodate |= PARAMETER5


| [[Array]] - A suitable empty position in format [[Position3D]] or [] if not found |= RETURNVALUE


|x1= <code>_position = _center_position findEmptyPosition[ 1 , 100 , "UH60M_EP1" ];)</code>|= EXAMPLE1
|x1= <code>_position = [[position]] [[player]] [[findEmptyPosition]] [0,100];</code>|= EXAMPLE1
|x2= <code>_position = _center [[findEmptyPosition]] [10,100,"UH60M_EP1"];</code>|= EXAMPLE2
|x3= Check if exact position is empty:
<code>_position = _center [[findEmptyPosition]] [0,0,"B_Boat_Armed_01_minigun_F"];</code>|= EXAMPLE3


____________________________________________________________________________________________
____________________________________________________________________________________________

Revision as of 12:00, 6 November 2013

Hover & click on the images for description

Description

Description:
Searches for an empty position around specified position. The search starts looking for an empty position at a minimum distance of [minDistance] from the [center] and looks as far away as [maxDistance]. If a [vehicleType] parameter is specified, then the search will look for an empty positions that is big enough to hold that vehicle type. If an empty position isn't found, an empty array is returned. This command ignores moving objects present within search area.
Groups:
Uncategorised

Syntax

Syntax:
center findEmptyPosition [minDistance, maxDistance] or [minDistance, maxDistance, vehicleType]
Parameters:
center: Array - Search area center position. Accepts Position2D, Position3D, PositionATL or PositionASL
[minDistance, maxDistance, vehicleType]: Array
minDistance: Number - Start searching no closer than minDistance from the center
maxDistance: Number - Stop searching no further than maxDistance from the center
vehicleType: String - Class name of a vehicle to accommodate
Return Value:
Array - A suitable empty position in format Position3D or [] if not found

Examples

Example 1:
_position = position player findEmptyPosition [0,100];
Example 2:
_position = _center findEmptyPosition [10,100,"UH60M_EP1"];
Example 3:
Check if exact position is empty: _position = _center findEmptyPosition [0,0,"B_Boat_Armed_01_minigun_F"];

Additional Information

See also:
selectBestPlacesisFlatEmpty

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

Posted on March 6, 2012
old_man_auz
I think the radius parameter should be treated as a 'minimum distance' from the centre position. I found that the parameter name radius wasn't very clear. Also, if radius is greater than max distance then the function will always return an empty array. Here is an snippet of code I use to find a safe landing zone for an extraction helicopter. It may be useful for someone. _centre = [ getMarkerPos "marker" , random 150 , random 360 ] call BIS_fnc_relPos; _extraction_point = []; _max_distance = 100; while{ count _extraction_point < 1 } do { _extraction_point = _centre findEmptyPosition[ 30 , _max_distance , "UH60M_EP1" ]; _max_distance = _max_distance + 50; }; In the above example, make sure that "_max_distance" is greater than 30, otherwise the while loop will go forever.

Bottom Section