PhotonTeamsManager Showing 0 player in room although there is some player

public bool CanJoin(PhotonTeam newTeam)
        Debug.Log(_teamSize + " is Team Size");
        bool canJoin = false;
        Player[] players = null;
        if (PhotonTeamsManager.Instance.TryGetTeamMembers(newTeam.Code, out players))
            if (players.Length < _teamSize)
                canJoin = true;
                Debug.Log($"{newTeam.Name} is full");
            Debug.Log(newTeam.Code+" "+newTeam.Name+" "+""+_teamSize+" "+players.Length +" is Player Length" + canJoin);
        return canJoin;
I have check wheather it is worrking correctly or not by last Debug line and I found that player.length is always 0 althoth there are some player .

How can I fix this problem ?


  • I suspect you have made some assumptions that are not valid. What one does in this case is verify your assumptions. So... log the newTeam.Code and try GetAvailableTeams() and see if it has a name or code that is not what you expect.

    It appears there is a GetTeamMembersCount() method as well so you don't really need a collection of Player objects unless you have a use for them individually.

  • @tleylan this below line always return 0 although there are some Players in team

    what might be the possible causes ?

     int teamCount = PhotonTeamsManager.Instance.GetTeamMembersCount(newTeam.Code);
  • I would expect that there are actually no members in that newTeam.Code.

    Find a way to list the teams so you can see the codes. Pass one of these values as a constant to the method and see what you get.

    There is no reason to suspect that the method doesn't work so I would check your code. Check what is calling CanJoin for instance and the parameter it is passing.

  • @tleylan How can I correctly implement team system ? I am stuck at this point since few month : (

    when a player joins room , I want that player join team with insufficient team member .

  • @Saphal Oops, I haven't been reading here for awhile. If it isn't too late try what I mentioned for this and any other "bugs". Confirm your assumptions. Debug.Log any values and any comparisons so you know your assumptions are in fact true.

    People assume things all the time it isn't hard to test those assumptions to be assured some simple value isn't the culprit.

  • I also encountered this problem, the value of GetTeamMembersCount() is always 0, my solution is: After the OnJoinedRoom() callback, join the team for player, so that you can use GetTeamMembersCount() to do some operations such as room player assignment team after receiving the OnPlayerJoinedTeam() callback,Hope this works for you。