Get nearby entities||doc135401

September 20, 2022

Format

 Map:getNearbyEntities(pos, maxDistance) 
  • The class to which the function belongs:Map

Description

Returns a table of entity objects within a specific distance from the specified coordinates.


Precautions

  • The content of the object table is an ordered table composed of object instances.

Parameters

Variable name type Description
pos Vector3 coordinate
maxDistance float maximum distance


Value Returned

type Description
table entity object table


Code Samples

on the server sideglobal script, get the solid object within 10 block units around the 0,0,0 coordinates.

local map = World.CurWorld:getMap("map001")
local entities = map:getNearbyEntities({x = 0, y = 0, z = 0}, 10)
for _, entity in ipairs(entities) do
    print(entity.objID, entity.name)
end