Cant join a room after completing a game

Options

Hello,

When I create a room and other players join my room I can start the game normally using my Start Game button, But when my game is finished and I am back to the lobby and I try to create another room either with same name or other name my Start Game button no longer works, And yes all players leave the room when the game is finished. The Start Game button does gets pressed but the game scene does not load. Unless I leave the room and recreate it again, then it works.

Is this a bug or a timeout thing?

Here is code for my Start Button:

And here is the code for my Leave Game Button:


Answers

  • Tobias
    Options

    PUN has no known bugs that would affect buttons, so it is quite likely something you need to find in your project.

    Maybe it's just that you set the button to Interactable = false and that affects the next round?

    You don't have to RemoveBufferedRPCs when you leave a room. Apparently you closed the room, so nobody is joining and the buffered events are not sent again. They are cleaned up when the room is empty.

  • BHS
    BHS
    edited March 2023
    Options

    Hey Tobi,

    After debugging a lot I found out what caused the problem.

    Basically this is how you can get the error:

    => Player 1 makes a room called ex: 123, Player 2 joins, they both play and finish the game and return to the lobby.

    => Now if Player 2 makes a room called the same name as previous one ex: 123, and Player 1 joins, and when Player 2 presses the Start Game button, the game no longer starts, although the button is getting pressed. (I also removed the button interactable = false but that didn't solved anything)

    So this time I removed the if(pv.IsMine) from the OnClickStartButton and I finally got an error message when Player 2 creates the room.

    This is the error message:

    I also found out that if I use the PhotonNetwork.AutomaticallySyncScene = true; and just call PhotonNetwork.LoadLevel("Test Scene"); without using an RPC it works as well but the problem with this is that sometimes it take a couple of seconds to load other players into the game scene, so for that reason I am using RPC AllViaServer to call the load level to all the players at the same time.