I can't get the amount of Team Members (PhotonTeamsManager)

Duck
Duck
Hello everyone,
I use PhotonTeamsManager for my teams. And this system actually worked earlier. But now I get a "Null Reference" error when I try to get the amount of team members.

This is my little code where I get the amount of team members in a team (byte GetTeamMembersLength) and the function AssignTeams() is called in Awake() by the MasterClient:
https://pastebin.com/GFH5scFf

The Error references to the following line, which is line 15 in Pastebin:
byte teamBluePlayers = GetTeamMembersLength("Blue");

But the actual error is in byte GetTeamMembersLength at line 4 in Pastebin, which is:
if(teamsManager.TryGetTeamMembers(teamName, out players))

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited April 2020
    Hi @Duck,

    Make sure teamsManager field is not null.
    Also, in PUN 2.18 (latest) we added TeamsManager.GetTeamMembersCount methods.
  • Hello @JohnTube

    thank you, I got an E-Mail in the morning from Unity that Photon Unity Networking 2 got updated. But thank you anyways. And teamsManager was not null. I don't know what the problem was, because it worked a few days ago, but it seems like it got fixed now.
    Wow, you're fast. This is the second time that you updated PUN 2 at the right time. The second time that you updated PUN 2 when I had a problem which has been fixed in this version. Thank you for your amazing support. In addition to the good prices, the fast servers and very important: You made Multiplayer easy, your support is also one of the reasons why I recommend Photon to other developers. That's the only reasonable and good Networking solution out there. And it's really good. Thank you for this!
    And usually when something gets updated, the update has some useless things and little bugfixes. But PUN 2 versions contain a lot of good stuff and fixes for huge bugs.