So I’m using the NetworkLobby package. My game is a two player game, but the players have no avatar in the game world, it’s more like chess. The concept of a ‘player’ makes it very hard to understand for me because it doesn’t apply to my game like it might for other games. I’m using empty ‘player’ objects because I just don’t have any need for them.
Anyway, when I start my game, it works fine. Then when I exit back the main menu, and try to start a second game, I get the error in the title. It’s like I didn’t clean up properly when exiting. My code for exiting is like so:
public void ReturnToMainMenu()
{
print("Stopping Host");
MyNetworkManager.Instance.StopHost();
MyNetworkManager.Instance.StopClient();
// MyNetworkManager.Instance.client.Disconnect();
//SceneManager.LoadScene(MyNetworkManager.Instance.lobbyScene);
}
I’m stopping the host and also the client for good measure, probably don’t need both but the result is the same even I just use StopHost(). Is there something else I need to do to clean up? The comments are old code reflecting my previous failed understanding of how to stop a game.
When I start a game the second time, I notice that the lobby creates two players instead of one. I have this print statement in my MyLobbyPlayer object.
public override void OnClientEnterLobby()
{
base.OnClientEnterLobby();
print("player entering lobby.");
}
This statement appears twice in my log on the second playthrough after returning to the main menu. Other threads on this issue aren’t the same as my issue, because people were getting this on the first run of their game, it almost seemed to be a bug that existed then inside NetworkLobby. But my issue is different.
I will need a lobby, but I don’t need ‘players’ in my game world. I can’t figure out how to handle this in a clean way.