State and RPC
Feature description
Section titled “Feature description”State and RPC are sub-capabilities of Multiplayer lobby. State synchronizes shared room or player data, while RPC triggers named logic in the room. Both are used after the player joins a room.
Supported engines
Section titled “Supported engines”| Engine | Status | Notes |
|---|---|---|
| Unity | Preview | Supports state set / get / reset and RPC register / call / unregister. |
| GameMaker | Not supported | The first GameMaker release does not include state or RPC. |
| Godot | In development | The preview runtime already has JSON state and RPC calls. |
Prerequisites
Section titled “Prerequisites”- The minimal Rooms flow is complete.
- A room has been joined.
- State keys and RPC names should remain stable.
- In Unity, if events need to be received, also place
IGPEventManagerin the scene.
By engine
Section titled “By engine”using System;using UnityEngine;using IGP.UnitySDK;
public sealed class IGPStateRpcDriver : MonoBehaviour{ [SerializeField] private IGPRuntimeManager runtimeManager;
public async void SetGlobalScore() { await runtimeManager.SetGlobalStateAsync("match.score", new { red = 1, blue = 0, updatedAt = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), }); }
public async void RegisterEchoRpc() { await runtimeManager.RegisterRPCAsync("sample.echo"); }
public async void CallEchoRpc() { var requestId = await runtimeManager.CallRPCAsync( "sample.echo", new { text = "hello" }, "all");
Debug.Log($"RPC request id={requestId}"); }}In-game ready state uses the same Arena player-state path and does not depend on Mirror:
await runtimeManager.SetGameReadyAsync(true);var states = runtimeManager.GetGameReadyStates( new[] { "player-a", "player-b" });The getter returns false when the player or key is missing and otherwise reads the gameReady boolean directly. It does not coerce malformed state, and room isReady, room status, and Mirror NetworkClient.ready do not affect the result.
To receive state and RPC events, place IGPEventManager in the scene and listen to its state-change and RPC events.
GameMaker currently does not support state or RPC.
using Godot;using IGP.GodotSDK.Autoload;
public partial class StateRpcPanel : Control{ private IGPGodotAutoload IGP => GetNode<IGPGodotAutoload>("/root/IGP");
public async void SetGlobalScore() { await IGP.SetStateJsonAsync( "global", "match.score", "{\"red\":1,\"blue\":0}"); }
public async void RegisterEchoRpc() { await IGP.RegisterRpcAsync("sample.echo"); }
public async void CallEchoRpc() { await IGP.CallRpcJsonAsync( "sample.echo", "{\"text\":\"hello\"}", "all"); }}Self-test
Section titled “Self-test”| Engine | Checkpoint |
|---|---|
| Unity | State changes are received after setting state; registered RPCs can be called and responses received. |
| GameMaker | State and RPC validation is not performed currently. |
| Godot | SetStateJsonAsync, GetStateAsync, and CallRpcJsonAsync can complete in sequence. |
Troubleshooting
Section titled “Troubleshooting”- State cannot be read: confirm scope and key match exactly.
- RPC is not triggered: first confirm the corresponding RPC name has been registered.
- Unity does not receive events: confirm
IGPEventManagerexists in the scene and related events are bound. - Godot JSON fails: validate with a simple object string first, such as
{"value":1}.