Get free interest goups to join in


what I'm trying to do is when I connect to a room I want to find the first interest group not used by anyone and subscribe to it.

Atm, what I'm using is the actor number as an interest group, but of course, this is not really smart because the actor number changes only progressively so it can easily overflow the 255 spaces available for the interest groups.

What can I do? Thanks!


  • JohnTube
    JohnTube ✭✭✭✭✭
    edited November 2021

    Hi @PixelFireXY,

    Thank you for choosing Photon!

    Good question! Sadly there is no built-in way to query which interest groups are used and which are free. You need to come up with your own custom algorithm for handling this. Maybe use actor or room properties for this? You could use PlayerNumbering script from PUN (or get inspired from it) where you assign a player index from that does not exceed MaxPlayers or PlayersCount.

    But first, why do you need more than 255 actor numbers?

    • Room can have more than 255 players? MaxPlayers = 0 or MaxPlayers 255
    • Room can stay alive long enough for players joining and leaving until ActorNumber exceeds 255?
  • Thank you @JohnTube for the answer, I'm going to try this right away!

    But first, why do you need more than 255 actor numbers?

    Each room has a maximum number of 255 players. Every time a new player joins the room, he gets a "free spot" interest group number.

    So, every time another player enters the local player's range, this one subscribes to the other player's interest group end vice-versa.

    This is a work-around to allow players to talk to each other only if the other player is in range and like this, manage group chats. Of course, the 255 threshold number it's just a worst-case scenario.

    I know there is a demo for the proximity voice but instead of using OnTriggerEnters and PhotonViews, we decided to use this solution instead. 🙂

  • PixelFireXY
    edited December 2021

    Hi @JohnTube ,

    in the end, we decided to directly use our custom non-Photon server to calculate the free interest groups for the players because the room custom properties were too complicated, hard to maintain and too inefficient to use.

    Thanks anyway, I wanted to share the feedback for who will fall into the same problem. 🙂