findEmptyPosition: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - " \{\{GameCategory\|[a-z]+[0-9]?\|Scripting Commands\}\}" to "") |
Lou Montana (talk | contribs) m (Text replacement - " \| *(game[0-9]|version[0-9]|gr[0-9]|serverExec|mp|pr|descr|s[0-9]|p[0-9]{1,3}|r[0-9]|x1?[0-9]|seealso) *= +" to " |$1= ") |
||
Line 17: | Line 17: | ||
|descr= Searches for an empty position around specified position. The search starts looking for an empty position at a minimum distance of [radius] from the [center] and looks as far away as [radius + 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. The search area could be preloaded with [[findEmptyPositionReady]] command. See also: [[BIS_fnc_findSafePos]]. | |descr= Searches for an empty position around specified position. The search starts looking for an empty position at a minimum distance of [radius] from the [center] and looks as far away as [radius + 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. The search area could be preloaded with [[findEmptyPositionReady]] command. See also: [[BIS_fnc_findSafePos]]. | ||
|s1= | |s1= center '''findEmptyPosition''' [radius, maxDistance, vehicleType] | ||
|p1= center: [[Array]] - Search area center position in format [x,y] or [x,y,z] in which case z is ignored. Accepts [[Position2D]] or [[Position3D]] | |p1= center: [[Array]] - Search area center position in format [x,y] or [x,y,z] in which case z is ignored. Accepts [[Position2D]] or [[Position3D]] |
Revision as of 22:03, 19 June 2021
Description
- Description:
- Searches for an empty position around specified position. The search starts looking for an empty position at a minimum distance of [radius] from the [center] and looks as far away as [radius + 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. The search area could be preloaded with findEmptyPositionReady command. See also: BIS_fnc_findSafePos.
- Groups:
- Positions
Syntax
- Syntax:
- center findEmptyPosition [radius, maxDistance, vehicleType]
- Parameters:
- center: Array - Search area center position in format [x,y] or [x,y,z] in which case z is ignored. Accepts Position2D or Position3D
- [radius, maxDistance, vehicleType]: Array
- radius: Number - Start searching no closer than radius from the center
- maxDistance: Number - Stop searching no further than radius + maxDistance from the center
- vehicleType: (optional): 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 = (getPosATL 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
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
- Posted on November 6, 2013
- Killzone_Kid
- Keep search radius short and sweet, under 50 metres maybe. Searching big area takes long time and will result in your game stop responding until the search is over. isFlatEmpty is probably more suitable for a larger area search.
- 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 was not 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.