Unity Multiplayer Lobby UI

Hello everyone;
I have a question about my Multiplayer Game. I have added a total of 3 scenes (Game_Scene, Lobby_Scene, Menu_Scene) and I have also added these scenes to the NetworkManager component (Lobby_Scene Online and Menu_Scene Offline Scene) When the Host clicks the Start Button both players go to Game_Scene.

The problem is that when the client clicks the Join button in Menu_Scene the client goes to Lobby_Scene and the editor pauses the game and shows the following errors

-“Spawn scene object not found for 58C09684. Make sure that client and server use exactly the same project. This only happens if the hierarchy gets out of sync.”.

-“Could not spawn assetId=3f9e5fbe-e119-1944-3ba8-c43240baeab2 scene=58C09684 netId=2”

I click the pause button to continue and click the Start button in Lobby_Scene to start the game, the editor pauses the game again in the client and I have to click the pause button again to continue and finally I can play the game without any problem.

Here is my LobbyController Class.

public class LobbyController : NetworkBehaviour
{
[SyncVar]
string firstPlayerText = “”;
[SyncVar]
string secondPlayerText = “”;

[SerializeField] TMP_Text firstPlayer;
[SerializeField] TMP_Text secondPlayer;

private void Update()
{
    if (NetworkManager.singleton.numPlayers == 1)
    {
        firstPlayerText = "Player 1 is ready";
        secondPlayerText = "Waiting For Player...";
    }
    else if (NetworkManager.singleton.numPlayers == 2)
    {
        firstPlayerText = "Player 1 is ready";
        secondPlayerText = "Player 2 is ready";
    }

    firstPlayer.SetText(firstPlayerText);
    secondPlayer.SetText(secondPlayerText);
}

public void StartGame()
{
    ((RTSNetworkManager)NetworkManager.singleton).StartGame();
}

[Command]
public void CmdStartGameOnTheServer()
{
    
}

}

Here is my MainMenu Class.

public class MainMenu : MonoBehaviour
{
[SerializeField] private TMP_InputField addressInput = null;

public void HostLobby()
{
    NetworkManager.singleton.StartHost();
}
public void Join()
{
    string address = addressInput.text;

    NetworkManager.singleton.networkAddress = address;
    NetworkManager.singleton.StartClient();
}

}

Here is the RTSNetworkmanager Class.

public class RTSNetworkManager : NetworkManager
{
public void StartGame()
{
if (numPlayers < 2) { return; }

    ServerChangeScene("Game_Scene");
}

}

Here some ss from My Game. I am using ParrelSyyc.



1 Like

Privacy & Terms