er2.getNearestSoldier 131
Get nearest soldier to a specific location
Return value
| Return Type | Description |
|---|---|
| Squad | Returns the nearest soldier, nil if nothing is found |
Parameters
| Parameter | Type | Description |
|---|---|---|
| 1 | vec3 | Position to search from |
| 2 | bool | (Optional) Maximum distance to search from. When no value is set, 100m is default search radius |
Examples
Example 45
--get nearest soldier to position 0,10,0 within 1km
local nearestSold = er2.getNearestSoldier(vec3(0,10,0), 1000);
--print the name of the soldier, if there was any
if not (nearestSold == nil) then
print("Name: "..nearestSold.getName())
end