er2.getNearestSoldier 3

Get nearest soldier to a specific location


Return value

Return TypeDescription
SquadReturns the nearest soldier, nil if nothing is found

Parameters

ParameterTypeDescription
1vec3Position to search from
2bool(Optional) Maximum distance to search from. When no value is set, 100m is default search radius

Examples

--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

Back to Scripting API