Garry's Mod Wiki

util.TraceLine

table util.TraceLine( table TraceData )

Description

Performs a trace with the given trace data.

Clientside entities will not be hit by traces.

Arguments

1 table TraceData
The trace data to use. See Structures/Trace

Returns

1 table
Trace result. See Structures/TraceResult.

Can return nil if game.GetWorld or its physics object is invalid. This will be the case for any traces done before GM:InitPostEntity is called.

Example

Using a function callback as filter.

local tr = util.TraceLine( { start = LocalPlayer():EyePos(), endpos = LocalPlayer():EyePos() + EyeAngles():Forward() * 10000, filter = function( ent ) if ( ent:GetClass() == "prop_physics" ) then return true end end } ) print( tr.HitPos, tr.Entity )
Output: The trace will only hit prop_physics or world.

Page Links


Special Pages


Wikis

?

Render Time: 38ms

DB GetPage 5
Generate Html 12
SaveChanges (1) 9
Render Body 0
Render Sidebar 10