Rpc static class is the entry point for all remote procedure call functionality. Decorate methods with the RPC attributes and the engine code-generates the network plumbing. Use [Sync] and [HostSync] on properties to replicate state automatically.
RPC attributes
Apply one of the following attributes to aComponent or GameObjectSystem method to make it an RPC.
- Rpc.Broadcast
- Rpc.Host
- Rpc.Owner
The method runs on every connected client, including the host.
NetFlags
PassNetFlags to the attribute constructor to control reliability:
| Flag | Description |
|---|---|
NetFlags.Reliable | Guaranteed delivery with ordering. Default for all RPC types. |
NetFlags.Unreliable | No delivery guarantee. Lower overhead for high-frequency updates. |
NetFlags.HostOnly | Only the host is permitted to call this RPC. |
NetFlags.OwnerOnly | Only the owner of the GameObject is permitted to call this RPC. |
Rpc static properties
Rpc.Caller
The
Connection that initiated the current RPC call. Only valid inside an executing RPC method. Use this to identify who sent the message.Rpc.Calling
Returns
true when the current method is being executed as a result of an incoming remote call. Returns false when you are the local initiator.Filter methods
Filter methods restrict which connections receive an RPC. They return anIDisposable scope — use using to ensure the filter is removed after the call.
FilterInclude
Send the RPC only to connections that match the criteria.An explicit set of connections to include.
A single connection to include.
A delegate that returns
true for connections that should receive the RPC.FilterExclude
Send the RPC to all connections except those that match the criteria.An explicit set of connections to exclude.
A single connection to exclude.
A delegate that returns
true for connections that should not receive the RPC.Sync attributes
Mark aComponent property with [Sync] to have the engine automatically replicate it from the owner to all other clients every network tick.
SyncFlags
Poll the property getter for changes every tick instead of relying on the setter being called. Use this when the returned value can change without going through the setter — for example, a value driven by a physics simulation.
Interpolate the value between network ticks for smoother rendering. Supported types:
float, double, Angles, Rotation, Transform, Vector3.The host is authoritative for this value. Equivalent to
[HostSync].HostSync
[HostSync] is shorthand for [Sync( SyncFlags.FromHost )]. The host writes the value; all clients (including the owning client) receive it read-only.
NetworkObject properties
Every networkedGameObject exposes network state through GameObject.Network. The table below documents the most commonly used properties:
| Property | Type | Description |
|---|---|---|
IsOwner | bool | true if the local connection owns this object. |
IsProxy | bool | true if another connection owns this object. |
IsUnowned | bool | true if no connection currently owns the object. |
OwnerId | Guid | The Guid of the owning connection, or Guid.Empty if unowned. |
Creator | Guid | The Guid of the connection that originally spawned this object. |
IsProxy is the recommended guard for owner-vs-client branching. It returns true on every peer that does not own the object, including the host when another client owns it.Complete networked component example
Mark synced properties
Add
[Sync] to properties that should replicate from owner to clients. Use [HostSync] for host-authoritative values.