⇐ Index
GetUnitsInRange(<-startPos <-range <-isSquare <-is3D <-requireLOS <-enemyState <-builtState <-imperviousState) ->units
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 > “occupies land”.
For short range searches refer to the unit search analysis to see how the different parameters interact with finding units in a short range.
10 ->cellX 15 ->cellZ 20 ->range false ->isSquare true ->is3D true ->requireLOS 2 ->enemyState 1 ->builtState 1 ->imperviousState GetTerrain(<-cellX <-cellZ) 1 + ->terrain GetUnitsInRange( V3(<-cellX <-terrain <-cellZ) <-range <-isSquare <-is3D <-requireLOS <-enemyState <-builtState <-imperviousState) ->units