Skip to content

After updating to version 1.6.0 of Netcode for GameObjects, I can't call a ClientRpc from OnNetworkSpawn function. #2778

@Satiriano

Description

@Satiriano

After updating to version 1.6.0 (also tested 1.7.1) of Netcode for GameObjects, I can't call a ClientRpc from OnNetworkSpawn function on a different player object than host. This previously worked on (I think) 1.0.1 I was using before.

Below is the simple code I have attached to my player object (player is automatically spawned when connecting). It used to work fine before I updated to the newest version of netcode for gameobjects. Now it no longer does. There's no error message, no warning. I also tried ServerRpc that calls ClientRpc, but that also didn't work. The debug message does not appear on either client or host. Debugging in Rider shows me the flow hits TestDebugClientRpc, but it doesn't go inside the function.

It's worth noting that the ClientRpc/ServerRpc does work in onnetworkspawn on the host's player, but it doesn't work on the connecting player objects.

 public override void OnNetworkSpawn()
    {
        base.OnNetworkSpawn();

        if (IsServer)
        {
            TestDebugClientRpc();
        }
    }

    [ClientRpc]
    private void TestDebugClientRpc()
    {
        Debug.LogError("TestingClientRpc");
    }

Environment

  • OS: Windows
  • Unity Version: 2022.3.12f1
  • Netcode Version: 1.6.0 and 1.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions