findEmptyPosition: Difference between revisions
Jump to navigation
Jump to search
m (Replaced <code> with <sqf>) |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
Line 15: | Line 15: | ||
|gr1= Positions | |gr1= Positions | ||
|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 | |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, 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 can be preloaded with [[findEmptyPositionReady]] command. | |||
|s1= center [[findEmptyPosition]] [radius, maxDistance, vehicleType] | |s1= center [[findEmptyPosition]] [radius, maxDistance, vehicleType] | ||
|p1= center: [[Array]] - | |p1= center: [[Array]] - search area center position in format [x,y] or [x,y,z] in which case z is ignored. Accepts [[Position#Introduction|Position2D]] or [[Position#Introduction|Position3D]] | ||
|p2= | |p2= radius: [[Number]] - start searching no closer than {{hl|radius}} from the center | ||
|p3= | |p3= maxDistance: [[Number]] - stop searching no further than {{hl|radius + maxDistance}} from the center | ||
|p4= | |p4= vehicleType: [[String]] - (Optional) class name of a vehicle to accommodate | ||
|r1= [[Array]] - a suitable empty position in format [[Position#Introduction|Position3D]] or [] if not found | |||
|r1= [[Array]] - | |||
|x1= <sqf>_position = (getPosATL player) findEmptyPosition [0,100];</sqf> | |x1= <sqf>_position = (getPosATL player) findEmptyPosition [0,100];</sqf> | ||
Line 36: | Line 37: | ||
|x3= Check if exact position is empty: | |x3= Check if exact position is empty: | ||
<sqf>_position = _center findEmptyPosition [0,0,"B_Boat_Armed_01_minigun_F"];</sqf> | <sqf>_position = _center findEmptyPosition [0, 0, "B_Boat_Armed_01_minigun_F"];</sqf> | ||
|seealso= [[findEmptyPositionReady]] [[selectBestPlaces]] [[isFlatEmpty]] | |seealso= [[findEmptyPositionReady]] [[selectBestPlaces]] [[isFlatEmpty]] [[BIS_fnc_findSafePos]] | ||
}} | }} | ||
{{Note | |||
|user= Killzone_Kid | |||
|timestamp= 20131106181000 | |||
|text= 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. | |||
}} | |||
{{Note | |||
|user= old_man_auz | |||
|timestamp= 20120306005000 | |||
|text= 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. | |||
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. | Here is an snippet of code I use to find a safe landing zone for an extraction helicopter. It may be useful for someone. | ||
<sqf>_centre = [ getMarkerPos "marker" , random 150 , random 360 ] call BIS_fnc_relPos; | <sqf> | ||
_centre = [getMarkerPos "marker", random 150, random 360] call BIS_fnc_relPos; | |||
_extraction_point = []; | _extraction_point = []; | ||
_max_distance = 100; | _max_distance = 100; | ||
Line 64: | Line 65: | ||
</sqf> | </sqf> | ||
In the above example, make sure that "_max_distance" is greater than 30, otherwise the while loop will go forever. | In the above example, make sure that "_max_distance" is greater than 30, otherwise the while loop will go forever. | ||
}} | |||
Revision as of 16:29, 15 August 2022
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, 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.
- 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: Number - start searching no closer than radius from the center
- maxDistance: Number - stop searching no further than radius + maxDistance from the center
- vehicleType: String - (Optional) class name of a vehicle to accommodate
- Return Value:
- Array - a suitable empty position in format Position3D or [] if not found
Examples
- Example 1:
- Example 2:
- Example 3:
- Check if exact position is empty:
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 Nov 06, 2013 - 18:10 (UTC)
- 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 Mar 06, 2012 - 00:50 (UTC)
- 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. In the above example, make sure that "_max_distance" is greater than 30, otherwise the while loop will go forever.