PUN Wave Trigger Driver

Photon PUN Extension for Wave Trigger (New in 1.6.0)

Overview

PUNWaveTriggerDriver is the Photon Unity Networking (PUN) driver for WaveTrigger in External mode.

It uses a MasterClient authoritative detection model:

  • MasterClient detects trigger enter/exit using Unity physics

  • It replicates “inside” state to all clients via RPC

  • It optionally replicates activation/reset to all clients via RPC

  • All clients apply state locally using the WaveTrigger public API:

    • SetTriggerInside(bool)

    • ExternalActivate(bool scheduleLocalReset)

    • ExternalReset()

This keeps wave encounters synchronized across peers.


Requirements

  • Photon PUN 2 (PHOTON_UNITY_NETWORKING)

  • A PhotonView on the same GameObject (required)

  • A WaveTrigger assigned (or present on the same GameObject)

  • WaveTrigger should be set to ActivationMode.External

  • A RuntimeSpawner must exist in the scene

  • A trigger collider that represents the activation volume (BoxCollider.isTrigger = true on the WaveTrigger object)


Inspector Reference

Target

Target (target) The WaveTrigger driven by this component. If not assigned, it uses GetComponent<WaveTrigger>().


Authority Detection (MasterClient)

Activator Tag (activatorTag) Tag filter for the activator. If empty, tag filtering is disabled (layer filtering still applies).

Matching checks:

  • Collider object tag

  • Attached Rigidbody GameObject tag

  • Root transform tag

Activation Layers (activationLayers) Layer mask filter for which colliders are allowed to activate the trigger.


Wave Behavior

Auto Start On Enter (autoStartOnEnter) If true, when MasterClient detects a valid enter:

  • it sets inside=true across all clients

  • and triggers activation across all clients (if not already activated)

Schedule Local Reset On Start (scheduleLocalResetOnStart) If true, the activation RPC calls:

  • target.ExternalActivate(scheduleLocalReset: true)

This schedules a local reset on each client (offline-like behavior). Usually keep this false for deterministic network rules unless you explicitly want client-local reset timing.


Debug

Enable Logging (enableLogging) Enables local debug logs.

Verbosity (logVerbosity)

  • ErrorsOnly

  • Normal

  • Verbose


RPCs Used

This driver uses PUN RPCs on its PhotonView:

  • RPC_SetInside(bool inside)

    • Calls target.SetTriggerInside(inside) on all peers

  • RPC_Activate(bool scheduleLocalReset)

    • Calls target.ExternalActivate(scheduleLocalReset) on all peers

  • RPC_Reset()

    • Calls target.ExternalReset() on all peers


Runtime Behavior

Enter / Exit

  • Only the MasterClient responds to Unity trigger callbacks.

  • On valid enter:

    • Master sets _insideMaster = true

    • RPCs inside=true to all clients

    • If autoStartOnEnter and !target.IsActivated, RPCs activate to all clients

  • On valid exit:

    • Master sets _insideMaster = false

    • RPCs inside=false to all clients

Manual Master Controls

The driver also exposes optional manual hooks (MasterClient only):

  • MasterEnter()

  • MasterExit()

  • MasterActivate(bool scheduleLocalReset = false)

  • MasterReset()

These are useful for:

  • UI buttons

  • scripted encounters

  • console/debug tooling


  1. Add a WaveTrigger volume and assign its WaveSpawner

  2. Set WaveTrigger Trigger Driver Mode to External

  3. Add PUNWaveTriggerDriver to the same GameObject (or another object that also has a PhotonView and can reference the trigger)

  4. Ensure the driver GameObject has a PhotonView

  5. Configure filters:

    • Activation Layers: player layer(s)

    • Activator Tag: player tag or (empty) to disable

  6. Decide on behavior:

    • Auto Start On Enter: on for standard encounter volumes

    • Schedule Local Reset On Start: typically off


Runtime Snapshot (Editor / Development Builds)

The inspector snapshot maps to these debug values:

  • Is Connected And Ready

  • Is MasterClient

  • Inside (Master)

  • PhotonView.ViewID

  • PhotonView.IsMine

  • WaveTrigger reference

  • Wave IsActivated


Usage Notes

External mode is required

This driver expects to drive the trigger via:

  • SetTriggerInside

  • ExternalActivate

  • ExternalReset

Leaving the WaveTrigger in UnityPhysics mode risks duplicated activation (Unity triggers firing on multiple peers).

Deterministic resets

If you need deterministic resets across peers and late joiners, prefer:

  • a Master-driven reset decision (e.g., explicit MasterReset RPC) over:

  • per-client local reset timers

Last updated