Garry's Mod Wiki

TraceResult

Description

Table structure used as trace result. Default values are when the trace hits nothing.

See util.TraceLine and util.TraceHull.

Members

Entity Entity
The entity hit by the trace.

Default: NULL

number Fraction
This indicates the how much of your trace length was used from 0-1 (resultLength/originalLength).

Default: 1

number FractionLeftSolid
Given the trace started in a solid enviroment, this will return at what distance the trace left the solid from 0-1. Doesn't work if the trace hit a non-worldspawn entity.

Default: 0

boolean Hit
Indicates whether the trace hit something.

Default: false

number HitBox
The ID of the hitbox hit by the trace.

Default: 0

number HitGroup
HITGROUP enum describing what hitgroup the trace hit (not the same as HitBox).

Default: 0

boolean HitNoDraw
Indicates whenever the trace hit a no-draw brush.

Default: false

boolean HitNonWorld
Indicates whenever the trace did not hit the world.

Default: false

Vector HitNormal
The direction of the surface that was hit as a normal vector (vector with length of 1).

Default: Global.Vector(0, 0, 0)

Vector HitPos
The position the trace stopped. This will be the provided endpos if the trace hit nothing.
boolean HitSky
Indicates whenever the trace hit the sky.

Default: false

string HitTexture
The surface material (not texture) of whatever the trace hit. Will be **displacement** if the trace hit a displacement, and **studio** if it hit a prop.

Default: "** empty **"

boolean HitWorld
Indicates whenever the trace hit the world.

Default: false

number MatType
MAT enum of the material hit by the trace.

Default: 0

Vector Normal
The direction of the trace as a normal vector (vector with length of 1).

Equivalent to: ( traceRes.HitPos - traceRes.StartPos ):Normalize()

number PhysicsBone
The PhysObj ID that was hit.

Used for Entity:GetPhysicsObjectNum.

Default: 0

Vector StartPos
The origin of the trace. Will match the provided startpos.
number SurfaceProps
ID of hit surface property from scripts/surfaceproperties.txt. You can get the name using util.GetSurfacePropName.

Used for CEffectData:SetSurfaceProp.

Default: 0

boolean StartSolid
Indicates whenever the trace started in a solid enviroment.

Default: false

boolean AllSolid
True if the entire trace is inside a solid.

Default: false

number SurfaceFlags
The surface flags of the hit surface. See SURF enum.

Default: 0

number DispFlags
The displacement flags of the hit surface. See DISPSURF enum.

Default: 0

number Contents
The contents of the hit surface. See CONTENTS enum.