How to choose different teams one by one
I'm making an online first person shooter, and I've gotten to the point where i need teams. What i want to do is add the first player who joins to the red team, the second to the blue team, then third goes onto red etc. etc. The problem is, i have no clue how to do this at all. Can anyone help me with this? I'm using photon by the way. Thanks in advance!
Incredibly basic question. You should at least do some research and undertake some tutorials.
Answer by ChristianSimon · Mar 27, 2018 at 09:20 AM
Hi,
you can use PunTeams therefore. Whenever a client joins the room, he can compare the size of both teams and join the one which has fewer members or a certain team if both teams have equal number of members. To do so you can use PunTeams.PlayersPerTeam[PunTeams.Team.red].Count
(respectively for the blue team). To make sure that PunTeams work properly, please attach the PunTeams script to one of the game object in the scene.
The local player can join a team (the red team in this example) by using PhotonNetwork.player.SetTeam(PunTeams.Team.red);
.
Your answer
Follow this Question
Related Questions
Keeping an object in a multiplayer scene, when a player joins. 3 Answers
What's wrong with my script ? 0 Answers
Unity Photon Handle Match Data 0 Answers