Player.JoinTeam("SomeTeam") doesn't update the players team

Options
Duck
Duck
Hello everyone,
I have been asking much recently and that's not actually my style. I am actually an independent developer, but sometimes the networking stuff and it's errors are pretty confusing.
Now my problem is:
I am setting the team of every player in the room in Start() actually (in a method which is called in Start()). And exactly 3 seconds later, I try to get the team of the local player, but it gives me an error. And then I checked if the Team == null and it really is. But why? Does Player.JoinTeam() not update the team of the player immediately?

Does Player.JoinTeam("SomeTeam") even synchronize over Network if it's just called by the master client or is it just called locally which doesn't make sense. But I can't find another explanation.

Thank you already in advance

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Duck,

    Make sure the team exists (team name is case sensitive, team code is unique).

    Check the return value of JoinTeam.
    If it's false check the logs for warnings or errors.

    If you call JoinTeam inside rooms wait for callbacks (PhotonTeamsManager.PlayerJoinedTeam or IInRoomCallbacks.OnPlayerPropertiesUpdate).

    If you call JoinTeam outside rooms it should work right away.
  • Duck
    Options
    Hello @JohnTube
    Thank you for your answer. I checked everything. I checked the name, I tried to do this with the Team Code and I also wrote some code to print the codes. I really checked everything.
    But the only thing I missed is, that I assign the player to the team with the code 0. And I forgot that there is no team 0. It starts at 1. I'm used to start counting with 0, because it's usually like this in programming.

    Thank you very much for your answer and the time you took even at this day.

    Have a nice 1 May!