util.TraceLine
Description
Performs an infinitely thin, invisible ray trace (or "trace") in a line based on the input and returns a 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 unless hitclientonly is set to true.
See ents.FindAlongRay if you wish for the trace to not stop on first intersection.
See util.TraceHull for a "box" type trace.
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.
You can use r_visualizetraces
set to 1
(requires sv_cheats
set to 1
) to visualize traces in real time for debugging purposes.
Arguments
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.
