ents.FindInCone
From GMod Wiki
Revision as of 00:23, 17 August 2010 by Crazy Quebecer (Talk | contribs)
Function | |
Syntax |
ents.FindInCone( Vector Pos, Vector Dir, Float Distance, Float Radius ) Where is this used? |
Description: | |
Find all entities within a specified hemisphere or spherical cap - probably useful for Line Of Sight. | |
Returns: | Table : Entity |
Part of Library: | Ents |
Realm: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=Ents.FindInCone]Ents.FindInCone [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Description
The shape in which this function finds something is probably a spherical cap.
That means it's part of a sphere that has its center at vPos and is of radius fRadius.
That sphere is then cut at a plane perpendicular to vDir, in fDistance units from vPos.
Mathematically:
local DistV=E:GetPos()-vPos if DistV:Dot(vDir) > fDistance -- the plane and DistV:Length() < fRadius -- the sphere then add_to_list(E) end
Possible >= and/or <= instead of > and <
Example