Fusion Local Area Spawner Driver

Photon Fusion Extension for the Local Area Spawner (New in 1.6.0)

Overview

FusionLocalAreaSpawnerDriver is the Photon Fusion driver for LocalAreaSpawner that replicates inside/outside state using Fusion’s authority model.

Key behavior:

  • Trigger detection runs only on the peer(s) allowed by executionTarget.

  • State replication is always sent from StateAuthority via an RPC.

  • All clients apply the region state locally by calling:

    • LocalAreaSpawner.SetPlayerInRegion(bool)

This keeps region presence consistent across all peers while still allowing flexible “who runs detection” policies.


Requirements

  • Photon Fusion installed (FUSION_WEAVER)

  • A NetworkObject on the same GameObject (required)

  • A LocalAreaSpawner component (same object or child)

  • A trigger collider configured for detection (commonly the BoxCollider on the LocalAreaSpawner object)

  • LocalAreaSpawner should be set to ActivationMode.External (recommended)

  • Scene must be running in play mode (driver uses runtime trigger callbacks and Fusion ticks)

This driver enforces NetworkObject via:

  • [RequireComponent(typeof(NetworkObject))]

It is also ordered early:

  • [DefaultExecutionOrder(-50)]


Inspector Reference

Detection

Activator Tag (playerTag) Optional tag filter. If set, only colliders matching this tag are considered valid activators. Leave empty to disable tag filtering.

Matching checks include:

  • Collider tag

  • Attached Rigidbody GameObject tag

  • Root transform tag

Activator Layers (activationLayers) Optional layer mask filter. Leave as Everything to accept any layer.


Execution

Execution Target (executionTarget) Controls who is allowed to execute detection logic and participate in broadcasting.

Options and meaning:

  • Everyone

    • Trigger callbacks can run everywhere (useful for local-only behaviors)

    • Replication still only originates from StateAuthority (see below)

  • StateAuthorityOnly

    • Only the peer with StateAuthority processes trigger callbacks

  • ServerOnly

    • Only a dedicated server peer runs detection (will be false in modes without a server)

  • SharedModeMasterClientOnly

    • In Shared Mode, allows the “master client” semantics, and also allows StateAuthority

Important: regardless of this setting, the driver guards replication with Object.HasStateAuthority.


Debug

Enable Logging (enableLogging) Enables log output.

Verbosity (logVerbosity)

  • ErrorsOnly

  • Normal

  • Verbose (includes early-outs + filter decisions)


Authority & Replication Model

Detection authority (configurable)

Detection occurs via Unity trigger callbacks:

  • OnTriggerEnter

  • OnTriggerStay (safety net for missed enters/teleports)

  • OnTriggerExit

These callbacks only proceed when:

  • CanExecuteOnThisPeer() is true (based on executionTarget), and

  • Object.HasStateAuthority is true

So even if executionTarget is Everyone, the driver will not accept triggers unless the peer is StateAuthority.

Replication (always from StateAuthority)

Inside/outside is replicated to all peers using an RPC:

This ensures:

  • One authoritative source of truth

  • Deterministic, consistent region state across all clients


Runtime Behavior

On Spawned()

When the NetworkObject spawns:

  • The driver resolves the LocalAreaSpawner reference (GetComponent or child)

  • It forces the region to false (not inside) initially:

    • _region.SetPlayerInRegion(false)

  • It resets internal state tracking:

    • _isInsideAuth = false

    • _lastSentInside = false

This prevents stale state from previous sessions / scene replays.


Trigger detection (StateAuthority only)

When a valid activator collider enters/stays/exits:

  • If accepted, the driver updates _isInsideAuth

  • It applies the change immediately on the authority peer:

    • _region.SetPlayerInRegion(inside)

This gives instant local feedback on authority before replication arrives elsewhere.


Network tick replication (send-on-change)

In FixedUpdateNetwork():

  • If the peer can execute and has StateAuthority:

  • If _isInsideAuth differs from _lastSentInside:

    • Updates _lastSentInside

    • Sends RpcSetInside(_isInsideAuth) to all peers

This avoids spamming RPCs; it only sends when the inside state changes.


Applying replicated state (all peers)

When RpcSetInside is received:

  • The driver resolves the LocalAreaSpawner again (safe for late component init)

  • Calls:

    • _region.SetPlayerInRegion(inside)

This triggers:

  • LocalAreaSpawner.onPlayerIsInRegion(region, inside)

  • Trigger UnityEvents (OnTriggerEnterEvent, etc.)

  • Region UnityEvents (OnRegionEntered, etc.) …based on your 1.6.0 LocalAreaSpawner implementation.


  1. Add a LocalAreaSpawner with a BoxCollider trigger volume

  2. Set LocalAreaSpawner Trigger Driver Mode to External

  3. Add a NetworkObject to the same GameObject as the driver

  4. Add FusionLocalAreaSpawnerDriver

  5. Configure:

    • Activator Tag (optional)

    • Activator Layers

    • Execution Target (typically StateAuthorityOnly)


Common Troubleshooting

Region never activates

  • Confirm the object has StateAuthority on the peer you expect

  • Confirm the trigger collider is actually firing (Rigidbody presence, correct layers)

  • Confirm activationLayers includes the player collider’s layer

  • If playerTag is set, confirm it matches the player object/root/rigidbody object

Region flickers active/inactive

  • Multiple colliders may be entering/exiting rapidly (e.g., child colliders)

  • Restrict activationLayers

  • Use a tag filter

  • Prefer a single “activation collider” on the player

I set ExecutionTarget = Everyone but it still doesn’t work on clients

That’s expected: this driver still requires Object.HasStateAuthority to accept trigger callbacks and replicate state. ExecutionTarget affects eligibility checks, but StateAuthority remains the source of truth.

Last updated