Revision Difference
ents.FindInSphere#548754
<function name="FindInSphere" parent="ents" type="libraryfunc">
<description>
Gets all entities within the specified sphere.
<note>Clientside entities will not be returned by this function.
This function internally calls <page>ents.FindInBox</page> with some [radius checks](https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/sp/src/public/collisionutils.cpp#L256-L301).</note>
</description>
<realm>Shared</realm>
<args>
<arg name="origin" type="Vector">Center of the sphere.</arg>
<arg name="radius" type="number">Radius of the sphere.</arg>
</args>
<rets>
<ret name="" type="table">A table of all found <page>Entity</page>s. Has a limit of 1024 entities.</ret>
</rets>
</function>
⤶
⤶
<example>⤶
<description>Look for doors in the radius and open them</description>⤶
<code>⤶
for k,ball in pairs(ents.FindInSphere(self:LocalToWorld(Vector(0,0,75)), 50)) do⤶
if IsValid(ball) then⤶
if ball:GetClass() == "prop_door_rotating" then ball:Fire("open") end⤶
if ball:GetClass() == "func_door_rotating" then ball:Fire("open") end⤶
if ball:GetClass() == "func_button" then ball:Fire("use") end⤶
end⤶
end⤶
</code>⤶
⤶
</example>