Search Unity

  1. We have added dedicated sub-forums for UNet, the experimental MLAPI and Unity Transport Package. Please use the new forums to discuss related topics.
    Dismiss Notice
  2. How can our website serve you better? Give us your feedback. Take our survey and let us know.
    Dismiss Notice

Resolved RPC Calls don't work after switching scenes

Discussion in 'MLAPI' 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
     
unityunity