This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| 4rpl:commands:getunitsinrange [2021/09/13 18:12] – Usage note Karsten75 | 4rpl:commands:getunitsinrange [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 7: | Line 7: | ||
| ===== Description ===== | ===== Description ===== | ||
| Returns list of units in range of a given position. The returned list is sorted so that the first item in the list is the closest. | Returns list of units in range of a given position. The returned list is sorted so that the first item in the list is the closest. | ||
| + | |||
| + | :!: **Note:** The difference between this API and [[GetUnits]] is that this method performs a search around the specified coordinates for any units that leave a footprint on the map by occupying space. This can be more performant than GetUnits in situations where a smaller area is being searched, but it comes with a downside that it won't find flying units, **or land units that are currently moving**. Units occupy space as soon as they begin descending at their target location, they do not have to have touched the ground yet. If you need a method to find units regardless of whether or not they are occupying space, use GetUnits. \\ | ||
| + | Whether a custom unit occupies space can be controlled through the CMOD Settings: **Settings > Basic > " | ||
| + | |||
| + | For short range searches refer to the [[cw4: | ||
| + | |||
| + | |||
| ? startPos: | ? startPos: | ||
| : a [[V3]] (vector3) indicating the point to search outwards from. | : a [[V3]] (vector3) indicating the point to search outwards from. | ||
| Line 41: | Line 48: | ||
| ? 2 = | ? 2 = | ||
| : Only find units that are impervious. Things like ore deposits are impervious. | : Only find units that are impervious. Things like ore deposits are impervious. | ||
| - | |||
| - | :!: **Note:** Due to some technicalities units which do not occupy any space will never be detected by this command. Whether a custom unit occupies space can be controlled through the CMOD Settings: **Settings > Basic > " | ||
| ===== Examples ===== | ===== Examples ===== | ||
| Line 59: | Line 64: | ||
| GetUnitsInRange( V3(< | GetUnitsInRange( V3(< | ||
| </ | </ | ||
| - | |||
| - | === Usage notes === | ||
| - | GetUnitsInRange doesn' | ||
| - | |||
| === See Also === | === See Also === | ||
| - | * [[4rpl: | + | * [[GetUnits]] |
| | | ||
| < | < | ||