Trace module casts rays and sweeps shapes through the game world using
the same collision data the engine uses - static geometry, dynamic entities,
and tagged collision layers.
All trace functions are synchronous and return immediately. Create
a
TraceFilter once and reuse it across frames - this avoids per-call
allocation and lets you build up an ignore list over time.Overview
Filters
Create reusable trace filters from presets or custom configs.
Raycasts
Single and multi-hit rays, box / sphere / capsule sweeps.
Spatial queries
Visibility, solid checks, overlap spheres, closest point.
Results
TraceResult, OverlapResult, ClosestPointResult shapes.
Filters
Every trace function accepts an optional filter that controls what the trace collides with. Filters can be passed in three forms - pick whichever fits your situation:Trace.filter
TraceFilter. Pass a preset string for common
scenarios, or a configuration object for fine-grained control.
string
default:"bullet"
One of the built-in filter presets (see table below).
TraceFilter methods
Once you have a filter, you can tell it to skip specific entities.filter.ignore
filter.ignore
Adds an entity to the filter’s ignore list. Accepts a raw entity index
or any object with an
.index property (e.g. an Entity).filter.clearIgnore
filter.clearIgnore
Clears the ignore list so the filter collides with all entities again.
Raycasts
Trace.ray
start to end. The workhorse of the trace API -
use this for hit detection, aim checks, and penetration tests.
Vector
required
Ray origin, typically the player’s eye position.
Vector
required
Ray endpoint - the target position.
string | TraceFilter | FilterOptions
Collision filter. Defaults to
"bullet" if omitted.- Default filter
- Preset string
- Reusable filter
- Inline config
Trace.box
start to end. mins and maxs define
the box extents relative to the sweep origin.
Vector
required
Sweep origin.
Vector
required
Sweep destination.
Vector
required
Minimum corner of the box (negative offsets).
Vector
required
Maximum corner of the box (positive offsets).
string | TraceFilter | FilterOptions
Collision filter. Defaults to
"bullet".Trace.sphere
start to end.
Vector
required
Sweep origin.
Vector
required
Sweep destination.
number
required
Sphere radius in game units.
string | TraceFilter | FilterOptions
Collision filter. Defaults to
"bullet".Trace.capsule
start to end.
Useful for simulating player-sized collision hulls.
Vector
required
Sweep origin.
Vector
required
Sweep destination.
number
required
Capsule radius.
number
required
Half the height of the cylindrical section.
string | TraceFilter | FilterOptions
Collision filter. Defaults to
"bullet".Trace.rayAll
Vector
required
Ray origin.
Vector
required
Ray endpoint.
string | TraceFilter | FilterOptions
Collision filter. Defaults to
"bullet".number
default:"32"
Maximum number of hits to return. Clamped to
1..128.Spatial queries
Fast utility functions that answer spatial questions without giving you a fullTraceResult.
Trace.isVisible
true if nothing
blocks the path between from and to. Skips normal, material,
and entity resolution entirely - just a yes/no answer.
Vector
required
Start position (e.g. eye position).
Vector
required
Target position (e.g. enemy head).
Trace.isSolid
true if the given point is inside solid geometry. Useful for
checking whether a calculated position is valid or stuck in a wall.
Vector
required
World position to test.
Trace.overlapSphere
origin.
Vector
required
Center of the sphere.
number
required
Sphere radius in game units.
string | TraceFilter | FilterOptions
Collision filter. Defaults to
"bullet".Trace.closestPoint
maxDistance of origin.
Vector
required
Search center.
number
required
Maximum search radius in game units.
string | TraceFilter | FilterOptions
Collision filter. Defaults to
"bullet".Results
TraceResult
Returned byTrace.ray, Trace.box, Trace.sphere, Trace.capsule,
and each element of Trace.rayAll.
entity - populated when resolveEntity is true and the trace hit a dynamic entity:
surface - populated when resolveMaterials is true:
OverlapResult
Returned by each element ofTrace.overlapSphere.
ClosestPointResult
Returned byTrace.closestPoint.
Collision tags
Tags control which collision layers are included or excluded in a filter’sincludeTags / excludeTags arrays.
Recipes
Fast visibility check
Trace.isVisible is the fastest way to check line of sight - it skips
normal / material / entity resolution and just returns a boolean.