ENTITY:TestCollision
table ENTITY:TestCollision( Vector startpos, Vector delta, boolean isbox, Vector extents, number mask )
Description
Allows you to override trace result when a trace hits the entitys Bounding Box.
Your entity must have Entity:EnableCustomCollisions enabled for this hook to work.
This hook is called for
anim
type only.Arguments
Returns
1 table
Returning a
table
will allow you to override trace results. Table should contain the following keys, all optional:
- Vector
HitPos
- The new hitpos of the trace. - number
Fraction
- A number from0
to1
, describing how far the trace went from its origin point,1
= did not hit. - Vector
Normal
- A unit vector (length=1) describing the direction perpendicular to the hit surface.
Returning true
will allow "normal" collisions to happen for SOLID_VPHYSICS
and SOLID_BBOX
entities.
Returning nothing
or false
allows the trace to ignore the entity completely.
Example
Example taken from lua/entities/widget_base.lua