Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved RPC Calls don't work after switching scenes

Discussion in 'Netcode for GameObjects' started by nhulston, Jun 14, 2021.

  1. nhulston

    nhulston

    Joined:
    Nov 26, 2019
    Posts:
    3
    If I run an RPC call from the first scene in which the NetworkManager's GameObject is created, RPC calls work. However, once I switch the scene with
    Code (CSharp):
    1. NetworkSceneManager.SwitchScene(mySceneName);
    RPC calls no longer work.

    I currently have a simple rpc call:
    Code (CSharp):
    1.     [ServerRpc(RequireOwnership = false)]
    2.     void SubmitAnswerServerRpc()
    3.     {
    4.         Debug.Log("Test");
    5.     }
    And the game object that this script is a part of is in the scene after switching, not the first scene, so the game object definitely exists when it should be called.

    I even have a helper method that calls SubmitAnswerServerRpc() with its own Debug.Log statement which goes through fine, but the rpc debug logs don't go through

    Thanks
     
    Last edited: Jun 14, 2021
  2. nhulston

    nhulston

    Joined:
    Nov 26, 2019
    Posts:
    3
    SOLUTION: Host and client have to have the exact same C# script code. I am making a different UI for host and client which is why they're different projects, so make sure if you're doing something similar that any script with RPCs in it are the exact same in both projects