findEmptyPosition: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Added an example, a note and edited the description to be more clear about what the function does.)
Line 7: Line 7:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Search for the position nearest (up to maxDistance) to the center,with,the free area (vehicle of the given type can be placed anywhere) of the,given radius. When not found,empty array is returned.  |= Description
| Searches for an empty position around a center location.
 
The search starts looking for an empty position at a minimum distance of [radius] from the [center] and looks as far away as [maxDistance].
 
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
____________________________________________________________________________________________
____________________________________________________________________________________________


Line 21: Line 27:




|x1= <code>(example)</code>|= EXAMPLE1  
|x1= <code>_position = _center_position findEmptyPosition[ 1 , 100 , "UH60M_EP1" ];)</code>|= EXAMPLE1  


____________________________________________________________________________________________
____________________________________________________________________________________________
Line 34: Line 40:
<dl class='command_description'>
<dl class='command_description'>
<!-- Note Section BEGIN -->
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on March 6, 2012
<dt class="note">'''[[User:old_man_auz|old_man_auz]]'''
<dd class="note">
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.
<code>_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;
};
</code>
In the above example, make sure that "_max_distance" is greater than 30, otherwise the while loop will go forever.


<!-- Note Section END -->
<!-- Note Section END -->

Revision as of 01:50, 6 March 2012

Hover & click on the images for description

Description

Description:
Searches for an empty position around a center location. The search starts looking for an empty position at a minimum distance of [radius] from the [center] and looks as far away as [maxDistance]. 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.
Groups:
Uncategorised

Syntax

Syntax:
center findEmptyPosition [radius,maxDistance] or [radius,maxDistance,vehicleType]
Parameters:
center: Array -
[radius,maxDistance,vehicleType]: Array -
Return Value:
Array

Examples

Example 1:
_position = _center_position findEmptyPosition[ 1 , 100 , "UH60M_EP1" ];)

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