menu_bookDocumentation

Triggers: Non-Blocking Collision Detection with ITriggerListener

calendar_today May 20, 2026 schedule ~1 min read person PatrickJr verified 50

A trigger is a collider that detects when other physics objects enter or exit it without blocking their movement. Useful for pickup zones, death planes, checkpoints, and area detection.

Setting Up a Trigger

Any collider can become a trigger by ticking Is Trigger in the inspector, or in code:

CSHARP
var box = AddComponent<BoxCollider>();
box.Scale = new Vector3( 200, 200, 100 );
box.IsTrigger = true;

Reacting to Trigger Events

Implement Component.ITriggerListener on any component on the same GameObject as the trigger collider:

CSHARP
public sealed class PickupZone : Component, Component.ITriggerListener
{
    public void OnTriggerEnter( Collider other )
    {
        Log.Info( $"{other.GameObject.Name} entered the pickup zone" );
    }

    public void OnTriggerExit( Collider other )
    {
        Log.Info( $"{other.GameObject.Name} left the pickup zone" );
    }
}

Overloads provide both colliders (useful with multiple triggers on one GameObject):

CSHARP
public void OnTriggerEnter( Collider self, Collider other ) { }

GameObject variants if you only care about the entering object:

CSHARP
public void OnTriggerEnter( GameObject other ) { }
public void OnTriggerExit( GameObject other ) { }
Note: The default player controller uses two child colliders (capsule body + box feet). When entering a trigger, you may get two events. Use FindMode.InAncestors to check for the player component in the parent.

Polling with Collider.Touching

If you prefer polling over events, Collider.Touching gives all colliders currently overlapping:

CSHARP
[Property] public BoxCollider Box { get; set; }

protected override void OnUpdate()
{
    foreach ( var collider in Box.Touching )
    {
        Log.Info( $"{collider.GameObject.Name} is inside the box" );
    }
}
OnTriggerExit fires automatically when a collider inside the trigger is disabled or destroyed.
Was this helpful?