util.TraceLine
Description
Performs an infinitely thin, invisible Ray Trace (or "Trace") in a line based on an input Trace Structure table and returns a Trace Result table that contains information about what, if anything, the Trace line hit or intersected.
Traces intersect with the Physics Meshes of Solid, Server-side, Entities (including the Game World) but cannot detect Client-side-only Entities.
For a way to detect Client-side Entities, see ents.FindAlongRay.
Traces do not differentiate between the inside and the outside faces of Physics Meshes. Because of this, if a Trace starts within a Solid Physics Mesh it will hit the inside faces of the Physics Mesh and may return unexpected values as a result.
See util.TraceHull for a "box" type trace.
You can use r_visualizetraces
set to 1
(requires sv_cheats
set to 1
) to visualize traces in real time for debugging purposes.
Arguments
For the table's format and available options see the Trace structure page.
Returns
nil
if the trace is being done before the GM:InitPostEntity hook.
For the table's format and available options see the TraceResult structure page.
Example
Using a function callback as filter.
Example
Visualizes a trace.