Garry's Mod Wiki

Revision Difference

ents.FindAlongRay#561877

<function name="FindAlongRay" parent="ents" type="libraryfunc"> <description>Returns a table of all entities along the ray. The ray does not stop on collisions, meaning it will go through walls/entities. This function is capable of detecting clientside only entities. ⤶ <note>This internally uses a Spatial Partition to avoid looping through all entities.</note>⤶ ⤶ This internally uses a Spatial Partition to avoid looping through all entities.</description> <realm>Shared</realm> <args> <arg name="start" type="Vector">The start position of the ray</arg> <arg name="end" type="Vector">The end position of the ray</arg> <arg name="mins" type="Vector" default="nil">The mins corner of the ray</arg> <arg name="maxs" type="Vector" default="nil">The maxs corner of the ray</arg> </args> <rets> <ret name="" type="table">Table of the found entities. There's a limit of 1024 entities.</ret> </rets> </function> <example> <description>Example usage of this function, as a "trace" of sorts.</description> <code> concommand.Add( "test_trace", function( ply ) local plyTr = ply:GetEyeTrace() local ents = ents.FindAlongRay( plyTr.StartPos, plyTr.HitPos ) PrintTable(ents) end )</code> </example>