[Duplicated] Getting an "InvalidOperationException: Behaviour not initialized: Object not set."...

edited June 17 in Fusion


I am trying to sync a game launch event for a multiplayer game from a game session.

The following is my instance RPC, the networked variable and place I call it from:

    [Networked(OnChanged = nameof(OnStateChanged))] 
    public NetworkBool LaunchGame { get; set; }


    // if player count for a session is full, launch game
    Debug.Log("Player count reached."); // this line is printed out in the console
    RPC_LaunchGame(true); // any other Log statements aren't printed past this line

    [Rpc(sources: RpcSources.All, targets: RpcTargets.All)]
    public void RPC_LaunchGame(NetworkBool state) LaunchGame = state; 


    private static void OnStateChanged(Changed<GameLauncher> changed)
        if(changed.Behaviour) changed.Behaviour.startGame();

I get the following Exception:

InvalidOperationException: Behaviour not initialized: Object not set.
Fusion.NetworkBehaviourUtils.ThrowIfBehaviourNotInitialized (Fusion.NetworkBehaviour behaviour) (at <147a77adcf864b659935f862fe8f5e7b>:0)

I'm not sure if i'm missing any necessary steps for using RPCs.

From using Log statements, I'm certain the the exception is thrown when the program reaches :


Any advice for using RPCs would be appreciated

This discussion has been closed.