Questions regarding PUN implementation approach

Options
Hi,
I'm trying to implement multiplayer in my Unity project using Photon and I need some guidance.
I connect to the Photon server using the defined settings and join a lobby once connected.
PhotonNetwork.ConnectUsingSettings ();
public override void OnConnectedToMaster () {
    PhotonNetwork.JoinLobby ();
}
Then, the user is given a choice to either create a public room or a private room.
Before creating a room, the code checks if there is any suitable room the user can join. If not, a new room is created.
//Public room creation
RoomOptions options = new RoomOptions { MaxPlayers = 2, IsVisible = true, PlayerTtl = -1 };
PhotonNetwork.CreateRoom (*SomeRoomName*, options, null);

//Private room creation
RoomOptions options = new RoomOptions { MaxPlayers = 2, IsVisible = false, PlayerTtl = -1 };
PhotonNetwork.JoinOrCreateRoom (*SomeRoomName*, options, null);
Once all players join the room, the game starts.
If a player disconnects midway, he can rejoin if the room is still active.
Once the user reconnects, the other player sends him the game state using a RPC.
Is there any better approach to achieve this?

I also have a few other questions:
1. Sometimes the cached room list returns a count of 0 even when a room is created. Why does this happen?
2. Is there any way I could save data on the Photon servers?

Thanks in advance!

Answers

  • Flarvain
    Options
    It all sounds pretty fine minus the 'Once the user reconnects, the other player sends him the game state using a RPC.'

    When you say this i'm wondering how you have been sending RPC calls up until then. There's an option for your PhotonTargets to use a buffered option which sends information that's relevant to new users joining a room. things like HP etc are good for this, is there any reason why that isn't used in your case?

    I may have mis interpreted your the other player sends him the game state.

    Cheers,