Joining Games in Progress

Options
I'm working on a space combat game in which players join the Photon room in a user interface/setup scene, then load into the space scene where the starfighters are flying around and blowing each other up.

I am using buffered RPCs to instantiate players in the user interface scene, and separate buffered RPCs to instantiate their starfighters after they load into the space scene, and then using PhotonViews to synchronize starfighter positions, health states, etc.

The problem I'm seeing is that you get massive framerate reductions as soon as you join a room in the user interface scene. The problem gets even worse the more players that have joined the game and are flying around in the space scene.

I'm not getting a massive amount of errors in the Unity log every frame that would explain this, so I was wondering if it might be possible that Photon is trying to send the View updates to players who have not yet instantiated the corresponding objects in their local simulation, and that some kind of internal error might be happening to cause the framerate issues.

My second question is more general: is this even a good architecture in the first place? Is allowing players to join a Photon room in one scene, then load into a different scene, necessarily making it so that some players are in one scene and others are in a different one despite being in the same Photon room, a really bad idea? Is there an easy way to make players who have not yet loaded into the space scene ignore network traffic from those who are in the space scene?

Any advice here would be greatly appreciated!

Comments

  • Are you using PhotonNetwork.Instantiate for the players? If you are, there is no reason to be using buffered RPCs, since when a new player joins the game, the other players will be automatically spawned client side. Then, you just start receiving the serialized positions, health stats, etc at that time. The only thing I buffer in an existing room for incoming players is anything that has transpired that a new player would need to know about that's not already kept track of with custom room properties. I'm sort of guessing, but the massive FPS drop you are seeing might be from the onslaught of buffered messages that your new player is receiving.
  • Hey FarmerJoe, thanks for the reply.

    I'm sorry, I was a bit misleading when I said I was instantiating players with an RPC. What I meant was that I am instantiating a "pilot" object for each player which keeps track of that player's score and her logical association with the chosen starfighter object (since starfighters can be swapped for new ones in-game.) The actual Photon player object is instantiated the way you would expect using the PhotonNetwork.JoinRoom() method.

    An onslaught of buffered messages is a good thought. My understanding, though, is that each client only buffers the most recent version of any given buffered call, even if that same buffered call is called several times before a new player joins. Is that correct? If so, that means that a joining player should only receive a maximum of three buffered calls from each already-connected client: one to instantiate a pilot, one to instantiate a starfighter (if they have launched one), and possibly one to de-instantiate a starfighter (if they have landed.)

    Furthermore, there is a noticeable framerate drop when only one client is already connected and has launched a starfighter in the space scene (two total buffered RPCs) when the second client connects to the game in the user interface scene.

    I will do some more testing to see if I can narrow down exactly what is causing the framerate drop. I'm still curious to know if there's any way to force certain clients to ignore network traffic from other clients in the same Photon room based on either arbitrary criteria or based on which scene is loaded, or if this is even necessary.
  • Another quick question: are buffered RPCs always received in the same order they were sent?
  • I'm not sure Ryan, but I would assume so. When you say "massive FPS drop", do you mean load lag basically? I actually am experiencing a bit of that in my game as well, with it getting worse the more people are already in the game. I assumed it was because my characters have lots of avatar-like parts that can be switched, so when a player joins the game, he/she needs to receive all the unique values from every other player. Although, I'm not sure why that would cause load lag for players already in the game (albeit it's minor at times). Not sure, I'm going to have run more tests.