Match players already in separate rooms?

Options
Hi,

I'm working on a 1v1 RTS game and after the match completes, I reload the current scene for both players with the idea being they match with each other to make playtesting easier. The problem is since they are connecting to Photon and creating an empty room (since no rooms exist according to the server) at roughly the same time, they miss each other. Is there anyway to remedy this?

I understand there is latency which is the cause of this but it would be great to recognize that there are two players by themselves in two separate rooms and then create a room for those two players if this is the case. Any insight on this? Thanks in advance.

Charles

Comments

  • Hi @czk,

    I'm not sure if I miss something here, but why do you disconnect the clients after the first game - at least as far as I understood. If the game has ended and both players are still in the same, wouldn't it be easier to just reload the scene? Maybe use another scene as transition in between?

    Besides that one option for testing you have is to add a simulated delay (different values for the clients) in order to wait a few 'seconds' before connecting or joining a room again.
  • czk
    Options
    Hi @Christian_Simon ,

    Thanks for getting back to me. That's a good idea and an oversight on my part, although when the scene reloads it tries to reconnect anyway so not sure what will happen if the users are already connected. I did your second suggestion and it works perfectly. Although it's not code that will ever go into production, this will work for now. Thanks!
  • Good to hear it's working now and you can test things out.

    Trying to connect when you are already connected will result in a warning or an error message. Nothing bad will happen, means clients don't get disconnected or something like this. If you want to check the reload scene option as well, you can surround the 'Connect' call with a if (!PhotonNetwork.connected) condition to make sure to not trying to connect 'again'.