findEmptyPosition: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) (Fix parameter) |
Lou Montana (talk | contribs) (Fix description) |
||
Line 15: | Line 15: | ||
|gr1= Positions | |gr1= Positions | ||
|descr= Searches for an empty | |descr= Searches for an empty area around the specified position, starting from the ''center'' looking for an empty ''areaRadius'' and looks as far away as ''areaRadius'' + ''maxDistance''. | ||
This command ignores moving objects present within the search area. The search area can be preloaded with [[findEmptyPositionReady]] command. | This command ignores moving objects present within the search area. The search area can be preloaded with [[findEmptyPositionReady]] command. | ||
Latest revision as of 23:21, 20 December 2022
Description
- Description:
- Searches for an empty area around the specified position, starting from the center looking for an empty areaRadius and looks as far away as areaRadius + maxDistance. This command ignores moving objects present within the search area. The search area can be preloaded with findEmptyPositionReady command.
- Groups:
- Positions
Syntax
- Syntax:
- center findEmptyPosition [areaRadius, maxDistance, vehicleType]
- Parameters:
- center: Array format Position2D or Position3D - search area center position in format [x,y] or [x,y,z] in which case z is ignored
- areaRadius: Number - wanted area radius
- maxDistance: Number - stop searching no further than areaRadius + maxDistance from the center
- vehicleType: String - (Optional) classname of a vehicle to accommodate
- Return Value:
- Array - a suitable empty position in format Position3D or empty array [] 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.