How to get all of my players in the same room

Options

Hi,

I recently had to update to Unity 2020. I had used Photon Pun 1 before that and moved to Photon Pun 2.

I followed the tutorial example.

https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/lobby

So at OnConnectedTo Master I used JoinRandomRoom and when OnJoinRandomFailed() it will create new room with PhotonNetwork.CreateRoom.

Game is live now and I would like to have all my players at the same room. Max Players Per Room is 30 and I have 100 CCU plan.

First I wondered why the game is so quiet compared to what it used to be with Photon Pun 1. Of course it takes awhile for players to have the recent update. My game will soon reach 1 million downloads although it is small, it has always players.

But when I run the game on my Android device build and Unity editor at the same time, for some reason the game can't find the same room that exists.

When I build PC version of the game and run multiple windows of the game I can see the players. It works ok.

It looks like the players are scattered on different places depending if I run the game on my android device or PC. Maybe this is happening with my live game too. How could I get all my players on the same "server"? Does Photon separate players based on their location or something? Or is the JoinRandomRoom the problem? If I understand the code correctly, PUN2 is not creating new room with this code if there exists one already?

Best Answer

  • Tobias
    Tobias admin
    Answer ✓
    Options

    Clients usually detect which Photon server region is best for their connection. This may mean, Android selected a different region.

    Also, the Game Version string is used to separate players. PUN will add it's own version to keep players with different PUN versions separated (there may be breaking changes).

    There is a doc with a Matchmaking Checklist, which should help you find out what happens in your case.

    You can limit the available regions in the Dashboard as Region Whitelist per app.

Answers

  • Tobias
    Tobias admin
    Answer ✓
    Options

    Clients usually detect which Photon server region is best for their connection. This may mean, Android selected a different region.

    Also, the Game Version string is used to separate players. PUN will add it's own version to keep players with different PUN versions separated (there may be breaking changes).

    There is a doc with a Matchmaking Checklist, which should help you find out what happens in your case.

    You can limit the available regions in the Dashboard as Region Whitelist per app.

  • Kapteeni
    Options

    Hi Tobias, thank you for the help.

    I limited the region in the Dashboard like you adviced and right away everything started to look normal again! So happy about this. It just happened by one click of a button from your Dashboard. In this game the Multiplayer is more like social and visual element so everything works when you play alone and move around in different rooms in the fantasy world. But when you have other people wandering around with you it becomes much more alive and feels better.

    I noticed from the analytics that my games peak CCU is 77. In the game code I have set Max to 30 CCU. I would like to increase that right away to 90 CCU or make it so that the game gets the variable from my server so I can lower it if it seems to be too much.

    From

    PhotonNetwork.CreateRoom(null, new RoomOptions { MaxPlayers = 30 });

    To

    PhotonNetwork.CreateRoom(null, new RoomOptions { MaxPlayers = 90 });

    If I now keep the game version same and in the game code I change the Max from 30 to 90 like this, will it break something? I assume that the player who creates the room, defines the room size and it can be anything? So if my iPad version of the game is live and has set max users to 30 and in my Android version has set max users to 90 it should still work? It would depend who creates the room first?

    Juhani

  • Tobias
    Tobias admin
    edited December 2022
    Options

    Good to read that the Region Whitelist helped.

    CCU are not the same as MaxPlayers. The former defines how many concurrent players can be online in your app while the latter is per room / session. PUN's subscription is for 16 players per room. If you go above, you should reach out via mail first (developer@photonengine.com) and maybe we can't support the case.

    It would depend who creates the room first?

    Yes, it would depend on that.

  • Kapteeni
    Options

    Hi Tobias, thank you for the help. I'll try this next.

    Juhani