This document is about: V3 SHARED AUTHORITY
SWITCH TO

RPCs - Example Uses

RPCs are how you trigger ephemeral events across clients. The patterns below are the ones you will reach for most often. This page assumes familiarity with RPC Basics.

Why Shared-Authority Uses RPCs More

Because different clients own different objects, any cross-object action that writes state has to go through the owner - and an RPC is the way you do that. The common targets are:

  • TARGET_OWNER - the current owner of a specific networked object. Use this when one player needs to affect another player's object (apply damage, award a buff, hand off an item).
  • TARGET_MASTER - the master client. Useful for coordinating state that the master arbitrates (requesting a scene change, asking for a game-mode switch).

Owner and master are not always the same client. The master handles room-wide coordination; object ownership is per-replicator and can belong to any client. See Ownership Modes for how ownership is assigned and transferred.

Applying Damage

The shooter does not own the target, so it cannot write to the target's health directly. Instead the shooter sends an RPC to the target's owner; the owner applies the damage locally, and replication propagates the new value to every other client.

GDScript

# On the shooter, when a bullet hit is detected:
func _on_bullet_hit(target: Node):
    # target.take_damage is a callable bound to `target`. Because `target` has a
    # replicator child, Fusion routes through that replicator. TARGET_OWNER
    # delivers the call to whichever client currently owns `target`.
    Fusion.rpc_to(Fusion.TARGET_OWNER, target.take_damage, 25)

GDScript

# On the target:
@rpc("any_peer", "call_local")
func take_damage(amount: int):
    health -= amount
    if health <= 0:
        # Handle death on the owner. The replicated `health` update fans out automatically.
        _die()

The owner receives the call, decrements the replicated health property, and Fusion distributes the new value to all other clients on the next sync.

Common Patterns

Text Chat

Chat is a textbook fit for broadcast RPCs: one client sends, everyone receives, nothing needs to survive late joins.

GDScript

func _ready():
    Fusion.register_broadcast_receiver(self)

func _exit_tree():
    if Fusion:
        Fusion.unregister_broadcast_receiver(self)

@rpc("any_peer", "call_local")
func chat_message(sender: String, text: String):
    $ChatPanel.append_line("[%s]: %s" % [sender, text])

func send_chat(text: String):
    Fusion.rpc(chat_message, local_player_name, text)

For production-grade chat, consider Photon Chat - a separate Photon product with turnkey features like AI moderation and word filtering via compatible third-party integrations, out of scope for raw RPCs.

UI and One-Shot Effects

Short-lived effects - a sound, a particle burst, a screen flash, a toast - map naturally to RPCs. Use "call_local" in the @rpc annotation when the sender should also see the effect without a separate code path.

See Also

Back to top