Letting players enter game when ready

Right now I have this: In a given room, there's a moderator (master client, who created the room). The game actually "starts" when the he decides to start it, at which time he, and any other players who have signaled they're ready, "enter" the game by loading the game/map level. The not-ready players stay in the room, they just don't yet enter the map level until they signal that they're ready, at which time they, too, enter the map level.

The problem I'm having is that as soon as players enter the map level and start instantiating things, those objects are instantiated for everyone in the room, including those who are still in the "waiting" area, i.e., not signaled they're ready to enter the game/map level yet.

I've looked at using PhotonNetwork.isMessageQueueRunning to delay the processing of the instantiates, but that disables ALL communication I think, and I've considered setting PhotonNetwork.SetReceivingEnabled to false for the group that represents the map level, but I think then all the instantiates would just be dropped and never processed when a player decided he's ready to join in.

Is there an overall best practice or suggestion for accomplishing this goal? Again, the idea is to have a sort of "waiting room" area for players to gather in a room, and then move into the map level when they're ready.

Comments

  • Have you tried PhotonNetwork.InstantiateSceneObject?

    Whatever gets instantiated stays in the room. Granted only the current master client at the time can do it until someone else becomes the master client. From what I understand, it stays even for any player that gets spawned into the game.
  • Why you can't keep players in the lobby until they are ready to play? Lobbies are designed for tasks like that.
  • I would like for them to be able to see details of the room, maybe chat while waiting to start, and other tasks that are specific to this particular game that influence how the player enters the game (e.g., a player makes certain selections based on what is allowed for that room).
  • Instantiate and RPCs and basically all communication in a room can either be executed on the receiving end or not at all. If you would not execute incoming info, you can't process that someone is ready.
    So: Change your workflow to a model where players can only chat and set their ready-state but nothing else. PUN does not have any idea which communication you want to delay and which you need right away.

    When the game begins, close the room, so that no one will enter anymore. While loading, pause the message queue, so that anything meant for the new scene is executing in the new scene.
  • I think I'll try to make it work like this: The room creator/master/moderator, and all players joining the room, come first to a level with just a "waiting area" screen (script) that lists all the players and their status, lets them chat about which map to use, etc. Players can indicate when they're ready. Moderator starts whenever he wants, at which time everyone follows him into the map level. Those who were "ready" have the waiting area screen removed (script disabled), so they see the world and can start interacting with it. The not-ready players still see the waiting area screen, although all the game action is now taking place, they're receiving RPCs, etc. When they hit their Ready button, their waiting area screen also goes away and they effectively "join" the game at that time.

    The only glitch I imagine is, for the not-ready players, a brief interruption when the moderator starts the game and the map level loads. I can throw up a status/progress message during that time though, and hopefully it will be brief. Any thoughts on that approach?

    Update: I've implemented this and it seems to work for my purposes.