Garry's Mod Wiki

Revision Difference

Structures/TraceResult#517082

<cat>struct</cat> <structure> <description>Table structure used as trace result. Default values are when the trace hits nothing.</description> <fields>{{StructureField|Entity|Entity|The entity hit by the trace.|NULL</fields>⤶ <fields>⤶ <item name="Entity" type="Entity" default="NULL">The entity hit by the trace.</item>⤶ <item name="Fraction" type="number" default="1">This indicates the how much of your trace length was used from 0-1 (resultLength/originalLength).</item>⤶ <item name="FractionLeftSolid" type="number" default="0">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.</item>⤶ <item name="Hit" type="boolean" default="false">Indicates whether the trace hit something.</item>⤶ <item name="HitBox" type="number" default="0">The ID of the hitbox hit by the trace.</item>⤶ <item name="HitGroup" type="number" default="0"><page>HITGROUP</page> describing what hitgroup the trace hit (not the same as HitBox).</item>⤶ <item name="HitNoDraw" type="boolean" default="false">Indicates whenever the trace hit a no-draw brush.</item>⤶ <item name="HitNonWorld" type="boolean" default="false">Indicates whenever the trace did not hit the world.</item>⤶ <item name="HitNormal" type="Vector" default="\u003Cpage\u003EGlobal.Vector\u003C/page\u003E(0, 0, 0)">The direction of the surface that was hit as a normal vector (vector with [length](/gmod/Vector/Length) of 1).</item>⤶ <item name="HitPos" type="Vector">The position the trace stopped. This will be the provided endpos if the trace hit nothing.</item>⤶ <item name="HitSky" type="boolean" default="false">Indicates whenever the trace hit the sky.</item>⤶ <item name="HitTexture" type="string" default="\u0022**empty**\u0022">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.</item>⤶ <item name="HitWorld" type="boolean" default="false">Indicates whenever the trace hit the world.</item>⤶ <item name="MatType" type="number" default="0"><page>MAT</page> of the material hit by the trace.</item>⤶ <item name="Normal" type="Vector">The direction of the trace as a normal vector (vector with [length](/gmod/Vector/Length) of 1).</item>⤶ <item name="PhysicsBone" type="number" default="0">The <page>PhysObj</page> ID that was hit.⤶ ⤶ Used for <page>Entity:GetPhysicsObjectNum</page>.</item>⤶ <item name="StartPos" type="Vector">The origin of the trace. Will match the provided startpos.</item>⤶ <item name="SurfaceProps" type="number" default="0">ID of hit surface property from scripts/surfaceproperties.txt.⤶ You can get the name using <page>util.GetSurfacePropName</page>.⤶ ⤶ Used for <page>CEffectData:SetSurfaceProp</page>.</item>⤶ <item name="StartSolid" type="boolean" default="false">Indicates whenever the trace started in a solid enviroment.</item>⤶ <item name="AllSolid" type="boolean" default="false">True if the entire trace is inside a solid.</item>⤶ <item name="SurfaceFlags" type="number" default="0">The surface flags of the hit surface. See <page>SURF</page>.</item>⤶ <item name="DispFlags" type="number" default="0">The displacement flags of the hit surface. See <page>DISPSURF</page>.</item>⤶ <item name="Contents" type="number">The contents of the hit surface. See <page>CONTENTS</page>.</item>⤶ </fields>⤶ </structure> {{StructureField|number|Fraction|This indicates the how much of your trace length was used from 0-1 (resultLength/originalLength).|1}}{{StructureField|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.|0}}{{StructureField|boolean|Hit|Indicates whether the trace hit something.|false}}{{StructureField|number|HitBox|The ID of the hitbox hit by the trace.|0}}{{StructureField|number|HitGroup|<page>HITGROUP</page> describing what hitgroup the trace hit (not the same as HitBox).|0}}{{StructureField|boolean|HitNoDraw|Indicates whenever the trace hit a no-draw brush.|false}}{{StructureField|boolean|HitNonWorld|Indicates whenever the trace did not hit the world.|false}}{{StructureField|Vector|HitNormal|The direction of the surface that was hit as a normal vector (vector with [length](/gmod/Vector/Length) of 1).|<page>Global.Vector</page>(0, 0, 0)}}<item name="HitPos" type="Vector">The position the trace stopped. This will be the provided endpos if the trace hit nothing.</item>⤶ {{StructureField|boolean|HitSky|Indicates whenever the trace hit the sky.|false}}{{StructureField|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.|"**empty**"}}{{StructureField|boolean|HitWorld|Indicates whenever the trace hit the world.|false}}{{StructureField|number|MatType|<page>MAT</page> of the material hit by the trace.|0}}<item name="Normal" type="Vector">The direction of the trace as a normal vector (vector with [length](/gmod/Vector/Length) of 1).</item>⤶ {{StructureField|number|PhysicsBone|The <page>PhysObj</page> ID that was hit.⤶ ⤶ Used for <page>Entity:GetPhysicsObjectNum</page>.|0⤶ }}<item name="StartPos" type="Vector">The origin of the trace. Will match the provided startpos.</item>⤶ {{StructureField|number|SurfaceProps|ID of hit surface property from scripts/surfaceproperties.txt.⤶ You can get the name using <page>util.GetSurfacePropName</page>.⤶ ⤶ Used for <page>CEffectData:SetSurfaceProp</page>.|0⤶ }}{{StructureField|boolean|StartSolid|Indicates whenever the trace started in a solid enviroment.|false}}{{StructureField|boolean|AllSolid|True if the entire trace is inside a solid.|false}}{{StructureField|number|SurfaceFlags|The surface flags of the hit surface. See <page>SURF</page>.|0}}{{StructureField|number|DispFlags|The displacement flags of the hit surface. See <page>DISPSURF</page>.|0}}<item name="Contents" type="number">The contents of the hit surface. See <page>CONTENTS</page>.</item>⤶ ⤶ }}