isMessageQueueRunning and new players joining matchmaking

Options
Hello,

over the past weeks I have been working on the matchmaking and scene loading system for my dungeon game. I am running into problems syncing the networked objects when a new player joins an existing game. Let me explain how I am doing things first:

When a player joins/creates a room, the matchmaker waits until all player slots are filled (so that playerCount = maxPlayers). When this happens, a 3 second countdown is fired (not as RPC, just locally) and then the main game scene is loaded, player prefabs spawned after that. The codeflow is like this:

Countdown -> isMessageQueueRunning = false -> Application.LoadLevelAsync -> isMessageQueueRunning = true -> PhotonNetwork.Instantiate local player prefab.

This works when all the players are waiting for the countdown to start.

When a player joins a game currently in progress though, he is still going through the countdown sequence, but since he is already in the room, I must temporarily disable isMessageQueueRunning while the countdown happens, otherwise the other players will try and get synced.
Now, disabling the message queue also disables photon events, so I cannot know if OnPhotonPlayerLeftRoom is fired (to stop the countdown). Basically once the player goes in countdown, he only has one choice, to load the level, even if the other players have quit the game. Because the message queue is disabled, the local player won't receive this event, so he'll enter a potentially empty/finished game level.

If I don't disable the message queue when the player joins the room, then I get the message "Invalid Photon View with ID #001", I assume it's trying to process an RPC with a view that doesn't exist.

Is there a way to split the logic behind disabling receiving photon events and receiving buffered RPCs (PhotonNetwork.Instantiate) ? I would still like to receive the photon events, but not the buffered RPCs. The other way would be to remove the countdown, but I'd like to keep this.

I hope I explained my problem correctly, if you need more information, please ask!

Many thanks

Comments

  • Tobias
    Options
    I just skimmed through the post and are about to leave but I wanted to give you some feedback:

    You can't selectively disable events and RPCs. RPCs are also events and there is just one queue of incoming messages which is paused until you loaded.

    Maybe we can come up with some way to rearrange things next week.
    Could you close the room when you're about to start the countdown? So no one could join anymore? It's preventing a few players from joining maybe but they could as well another room...?
  • frostbyte
    Options
    Hi Tobias,

    thanks for your reply. Closing the room won't help, as I want players to join existing games. My problem is that players joining a room with a game already in progress, get the countdown but still receive RPCs, as far as I can tell. And isMessageQueueRunning won't help, as you said, since by disabling it I basically disable receiving any kind of events in Photon.

    A bit stuck here. Perhaps I am over-complicating things and there is a different way to implement a countdown in a matchmaker?
  • Tobias
    Options
    There are lots of ways to implement a countdown.
    Did you have a look at the InRoomRoundTimer which is coming with the package?
    You can base your timer on the server's timestamp and ignore it when it's finished already when you join.
  • frostbyte
    Options
    I am at work now, I will have a look at it when I go back home. Sounds like a solution.

    So basically having no countdown when a player is joining a game already in progress, and also having the countdown based on the server's timestamp when players are waiting for the game to start?