System GetNearestEntityByClass

From CryWiki

Jump to: navigation, search

System.GetNearestEntityByClass(vec3, number, string)

Description

Gets the entity that's closest to the given position

Arguments

  1. Center of the place to check
  2. Radius
  3. Classname of the entity

Returns

Table of the entity

Example

Lua (example)
local closeGrunt = System.GetNearestEntityByClass(g_localActor:GetPos(), 50, "Grunt");
if closeGrunt ~= nil then
  Log("The closest grunt got a "..closeGrunt.primaryWeapon);
else
  Log("No grunt found");
end


Personal tools