Question regarding logic of "Restart Game"

Hello there,

I'm trying to add a restart game/session type of functionality to our application. I was hoping it would be as simple as stopping the message queue and reloading the scene, then enable the message queue again but I think I might be missing some required steps.

It actually seems to work doing what I said above for the most part, except the player driving most of the logic, and in this case the player I initiated the RPC call on gets some error messages, while other players reload the scene just fine and can do everything normally.

First it throws some errors for received RPC's that have no PV existing anymore, so I'm guessing I need to clear those messages somehow, then it throws some errors for OnDestroy() being called, which I guess is it destroying the objects in the scene to rebuild?

And the final set of errors is "Cannot send messages when not connected; Either connect to Photon OR use offline mode!" Which means that that particular client never reconnected... while the other players did.

I'm mostly asking so I know to look for errors in my code, or if I am just missing a logic step needed, so any insight on this would be very helpful. If you need more detail to understand what's happening please let me know.

Thank you for your time and assistance!

Comments

  • Maybe the topic "Timing for RPCs and Loading Levels" on this page helps:
    http://doc.exitgames.com/en/pun/current/getting-started/feature-overview

    In general, RPCs are being executed in the order in which they arrived on the server (to be sent on). When you want to switch to a new scene, everyone has to do that at the same time. For new, joining players this means you should use also a room property. Those can be checked before RPCs are received. It will be complicated to mix clients with different scenes.

    This is not bullet proof really. If you have buffered events, they survive the scene switch in the server. You would have to clean those up.

    If you want a simple way to load a scene for all players, use PhotonNetwork.LoadScene() as described on the page linked above.
  • Thank you, Tobias.

    I think a big part of my problem was I still had buffered rpcs and I wasn't handling those at all. This seems to have cleaned up a lot of the issues.