Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Mirror Scene Loader on all Clients

Discussion in 'Multiplayer' started by Philipp_Goettler, Apr 29, 2024.

  1. Philipp_Goettler

    Philipp_Goettler

    Joined:
    Dec 11, 2021
    Posts:
    29
    Hey this is the first time I am working on a multiplayer game. So probably it is very simple :D.
    I got a Level selection map. Every player should have the authority to choose the next level they want to play.

    Now there is the problem, when the host picks the level, everybody loads into it perfectly. When another player/client picks a level, then there are those errors:
    upload_2024-4-29_13-3-18.png

    I also got the information to run the ClientRpc function on the server, but i dont know how.

    Code (CSharp):
    1. [ClientRpc]
    2.     public void LoadScene(string _sceneName)
    3.     {
    4.         SceneManager.LoadSceneAsync(_sceneName, LoadSceneMode.Additive);
    5.     }
    6.  
    7.     [ClientRpc]
    8.     public void OpenUI()
    9.     {
    10.         SceneManager.LoadSceneAsync("UI_InGame", LoadSceneMode.Additive);
    11.     }
    12.  
    13.     [ClientRpc]
    14.     public void UnloadScene(string _sceneName)
    15.     {
    16.         SceneManager.UnloadSceneAsync(_sceneName);
    17.     }
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,411
    That doesn't look like NGO but they're all the same: only the server can load a network scene. You need to send a ServerRPC and have the server load that scene. You may need to use the corresponding "network scene load" method though but this depends on the networking framework.

    The way you structured this you would end up with clients each loading a different scene. If you want clients to be in different scenes but in the same network sessions, you likely have to perform additional (possibly non-trivial) steps to accomplish this.