Can't create room after leaving one

I'm sure I'm missing a step or not understanding something. But I've just started using Photon for the first time. I have the latest package and am using Unity 2019.4LTS

I am making a simple 2 person board game. Both players can join easy enough just using JoinRandomRoom and if that fails, calling CreateRoom().

This flow works fine. When the game ends (and currently it's a days work, so I'm just handling the other player "leaving" the room when I close the build as "ending") I call LeaveRoom and return to my menu scene in the OnLeftRoom callback. However, I am getting an odd issue when I try to go through the flow again.

I get an error saying failed to create room. Sometimes the error says I'm on the Game Server sometimes I see that I'm connected to the Master Server but in a joining state. I've tried checking PhotonNetwork.IsConnectedAndReady and it's true. LeaveRoom documentation says "Leave the current room and return to the Master Server where you can join or create rooms". I tried waiting for OnConnectedToMaster as the error message suggests, but it never gets called.

The other oddity is i have some UI View logic that happens when OnJoinedRoom is called and despite the error, this callback is getting received. Since it's waiting for the other player, I start up another client and join. Their game loads as if the room exists, but on my local I see a warning
"PUN cancels an ongoing async level load, as another scene should be loaded. Next scene to load: Game"
And this end hangs waiting for the level to load

I'm most confused by the LeaveRoom seeming to not leave the room.

Trying to use Photon Realtime instead of PUN is tough. The docs don't always make it clear what I'm supposed to call. Am I supposed to be using the PhotonNetwork class to make these calls? Or is it different for Realtime?

Any assistance would be appreciated

Comments

  • Oh dear. Never mind. I made the oldest Unity mistake in the book. I had my network controller class as a DoNotDestroy in the menu scene. So I ended up with two when I returned. Moving that out to an initialise scene solved my problem
Sign In or Register to comment.