Garry's Mod Wiki

Revision Difference

ENTITY:TestCollision#514574

<function name="TestCollision" parent="ENTITY" type="hook">⤶ <ishook>yes</ishook>⤶ <description>⤶ Allows you to override trace result when a trace hits the entitys Bounding Box.⤶ ⤶ ⤶ ⤶ ⤶ <note>Your entity must have <page>Entity:EnableCustomCollisions</page> enabled for this hook to work</note>⤶ </description>⤶ <realm>Shared</realm>⤶ <predicted>No</predicted>⤶ <args>⤶ <arg name="startpos" type="Vector">Start position of the trace</arg>⤶ <arg name="delta" type="Vector">Offset from startpos to the endpos of the trace</arg>⤶ <arg name="isbox" type="boolean">Is the trace a hull trace?</arg>⤶ <arg name="extents" type="Vector">Size of the hull trace?</arg>⤶ <arg name="mask" type="number">The &lt;page&gt;CONTENTS&lt;/page&gt; mask</arg>⤶ </args>⤶ <rets>⤶ <ret name="" type="table">A table containing new HitPos, Fraction and Normal. Returning nothing allows the trace to ignore the entity completely.</ret>⤶ </rets>⤶ </function>⤶ ⤶ <example>⤶ <description>Example taken from lua/entities/widget_base.lua</description>⤶ <code>⤶ function ENT:TestCollision( startpos, delta, isbox, extents )⤶ ⤶ if ( isbox ) then return end⤶ if ( !widgets.Tracing ) then return end⤶ ⤶ -- TODO. Actually trace against our cube!⤶ ⤶ return ⤶ { ⤶ HitPos = self:GetPos(),⤶ Fraction = 0.5 * self:GetPriority()⤶ }⤶ ⤶ end⤶ </code>⤶ ⤶ </example>