Wave Trigger

Runtime Spawner includes a complete wave spawning system suitable for tower defense–style gameplay, horde modes, ambushes, and scripted “hold & defend” encounters (e.g., Left 4 Dead–style events).

A WaveTrigger defines when a wave sequence begins. The activation volume is defined by a BoxCollider set as a trigger.


Creating a Wave Trigger

To create a new Wave Trigger:

  1. Open the Runtime Spawner inspector.

  2. Click the “+” button in the Wave Triggers section.

This will:

  • Create a child GameObject

  • Add a WaveTrigger

  • Add and configure a BoxCollider (set to isTrigger = true)

Note WaveTriggers and WaveSpawnPoints do not need to be children of RuntimeSpawner (since 1.3.0). They can live in additively loaded scenes, prefabs, or procedural tiles added at runtime.


Fundamentals

WaveTrigger is an activation component, not a spawner.

It does not spawn enemies directly. Instead, it:

  • Detects when a wave should begin

  • Routes activation through the RuntimeSpawner

  • Manages trigger state, reactivation, and events

  • Provides designer-friendly UnityEvents and system-level C# events

Use a WaveTrigger to drive:

  • Scripted wave encounters (hordes, ambushes, defenses)

  • One-shot or repeatable combat arenas

  • Waves that start on player approach

  • Waves that start automatically at level start

  • Networked encounters driven deterministically by authority


Requirements

  • A BoxCollider on the same GameObject

  • BoxCollider.isTrigger = true

  • A RuntimeSpawner must exist in the scene

  • A WaveSpawner asset must be assigned

  • The collider is auto-assigned to TriggerZone in OnEnable()

For trigger events to fire in UnityPhysics mode:

  • At least one collider must have a Rigidbody (usually the player)


Responsibilities

WaveTrigger is responsible for:

  • Detecting activation conditions (UnityPhysics or External)

  • Starting and stopping wave sequences via RuntimeSpawner

  • Tracking whether the trigger is currently activated

  • Optionally rearming itself after a cooldown

  • Exposing UnityEvents and static events for gameplay systems

  • Providing optional spawn anchors (WaveSpawnPoints)


Key Properties

Trigger & State

BoxCollider TriggerZone The collider used as the activation volume. Auto-assigned and configured in OnEnable().

bool IsActivated (read-only externally) Indicates whether the wave trigger is currently active.

  • true while a wave sequence is running

  • Set internally by the trigger lifecycle

  • Cannot be set directly by external systems

bool IsInside Whether the trigger volume is currently occupied (inside state). Used for trigger events and external driver replication.

int ActiveWave Current wave index (0-based). Managed by the wave runner / RuntimeSpawner.


Wave Configuration

WaveSpawner WaveSpawner The wave table used when this trigger activates. Must be assigned for the trigger to function.

List<WaveSpawnPoint> WaveSpawnPoints Optional anchor points used during wave spawning.

When present:

  • Spawn locations are chosen from these anchors

  • Selection is handled by the wave system


Activation & Reactivation (Inspector)

bool startAutomatically When enabled, the trigger activates automatically once:

  • RuntimeSpawner is initialized, and

  • WaveTrigger has started

Useful for:

  • Survival mode openers

  • Scripted intro fights

bool reactivateTrigger If enabled, the trigger will reset after a cooldown and can activate again.

float reactivateTime Cooldown time (seconds) before the trigger becomes eligible again.


Trigger Driver Mode (New in 1.6.0)

ActivationMode

  • UnityPhysics – Uses OnTriggerEnter/Exit

  • External – Trigger is driven by an external system (Fusion / PUN)

This allows WaveTrigger to be used safely in networked games.


Public API (Designers & Drivers)

WaveTrigger is now API-driven. External systems must not mutate internal state directly.

Starting a Wave

This is the canonical activation path. It routes through RuntimeSpawner.ActivateWaveTrigger(this) and updates state/events consistently.

Stopping a Wave

External Activation (Networking)

Use this from authoritative networking drivers.

External Reset (Deterministic)

Cancels any local reset coroutine and returns the trigger to an eligible state.

External Occupancy (Replication)

Used by Fusion / PUN drivers to replicate trigger presence deterministically.


Events

Static C# Events (Systems)

Use these for:

  • Global encounter tracking

  • Director systems

  • UI/audio managers without scene references


UnityEvents – Trigger Occupancy

  • OnTriggerEnterEvent

  • OnTriggerStayEvent

  • OnTriggerExitEvent

  • OnTriggerStateChanged(bool inside)

These emulate trigger-style behavior and are useful for:

  • FX

  • Sensors

  • Debug visualizations


UnityEvents – Wave Lifecycle

  • OnWaveActivated

  • OnWaveCompleted

  • OnWaveDeactivated

  • OnWaveReset

Use these for:

  • Locking doors

  • Starting music

  • Updating UI

  • Progression hooks


Runtime Behavior & Lifecycle

Initialization & Registration

OnEnable

  • Assigns TriggerZone

  • Resets local state

  • Subscribes to RuntimeSpawner.onSpawnerInit

Start (Play Mode)

  • Finds RuntimeSpawner

  • Registers via RegisterWaveTrigger(this)

  • Optionally auto-starts if startAutomatically is enabled

OnDisable / OnDestroy

  • Unsubscribes from spawner events

  • Unregisters from RuntimeSpawner


Activation Flow

UnityPhysics Mode

  • OnTriggerEnter checks:

    • Correct tag

    • Spawner initialized

    • Not already activated

  • Calls StartWave()

  • Optionally schedules reset

External Mode

  • Unity triggers are ignored

  • External driver:

    • Sets inside state

    • Decides when to activate/reset

    • Calls public API methods


Reactivation

If reactivateTrigger is enabled:

  • Trigger schedules a reset after reactivateTime

  • On reset:

    • IsActivated becomes false

    • Reset events fire

    • Trigger becomes eligible again


Typical Usage Patterns

1. One-Shot Encounter Volume

  • startAutomatically = false

  • reactivateTrigger = false

Player enters:

  • Trigger activates

  • Wave plays once

  • Trigger never fires again


2. Repeatable Horde Zone

  • reactivateTrigger = true

  • reactivateTime = 30

Player enters:

  • Wave starts

  • After completion + cooldown, trigger resets

  • Can be reactivated on re-entry


3. Auto-Start Survival Wave

  • startAutomatically = true

  • Optional reactivation

On play:

  • Trigger waits for RuntimeSpawner

  • Wave starts automatically

  • No collider required


4. Manual Activation via Script (Updated)

This uses the same internal path as volume-based activation.


5. Global Monitoring (UI / Audio / Director)


Editor Helpers

AddSpawnpoint() Creates a new child WaveSpawnPoint and selects it.

ShowHide(bool) Controls whether the trigger volume gizmo is drawn.

OnDrawGizmos

  • Draws the trigger volume

  • Uses a distinct color when activated


Key Takeaways (1.6.0)

  • WaveTrigger is now API-driven, not state-mutable

  • Supports offline-first + deterministic networking

  • Clear separation between:

    • Occupancy (inside)

    • Activation (wave lifecycle)

  • Rich UnityEvents for designers

  • Clean integration path for Fusion and PUN drivers

Last updated