Garry's Mod Wiki

Trace

Description

Table structure used for util.TraceLine.

Members

Vector start
The start position of the trace

Default: Vector(0, 0, 0)

Vector endpos
The end position of the trace

Default: Vector(0, 0, 0)

Entity filter
Things the trace should not hit. Can be an entity, a table of entities, a table of entity classes or a function:
Function argument(s):
1 Entity ent - The entity that the trace hit
Function return value(s):
1 boolean ret1 - Return true to hit the entity, false to skip it.

Using a function here is super slow. Try to avoid it.

Default: nil

number mask
The trace mask MASK enum. This determines what the trace should hit and what it shouldn't hit. A mask is a combination of CONTENTS enum - you can use these for more advanced masks.

Default: MASK_SOLID

number collisiongroup
The collision group COLLISION_GROUP enum. This determines what the trace should hit in regards to the entity's collision group.

Default: COLLISION_GROUP_NONE

boolean ignoreworld
Should the trace ignore world or not

Default: false

table output
If set, the trace result will be written to the supplied table instead of returning a new table

Default: nil

boolean whitelist
Turns the filter field into a whitelist, if it is a table.
This was recently added in version (2024.05.16). It might only be available on the Dev Branch right now.

Default: false

boolean hitclientonly
Enables traces to hit clientside only entities. Keep in mind that most naturally spawned entities are classified as debris, so extra mask values might be required.
This was recently added in version (2024.05.16). It might only be available on the Dev Branch right now.

Default: false