How to make 2 teams in multiplayer system: friendly & enemy teams?


  1. i have to set random team joining like 3v3 and players join without their choice so we don’t ask which team you like
  2. when player joins a team, his team name and score should be blue and enemy stuff, red. its related to HUD but what to do for recognizing teams? i have no idea
    its my first multiplayer project. the session is done but the teams aren’t.
    so it looks simple but i need to know structure of team making in ue4
    thanks a lot :wink:

Use a struct containing two team (arrays). Team 1 (blue), Team 2 (red). On player join assign to a team by storing player id in the chosen array. Reference the struct as needed. Another option is to create a team variable in playerstate assign a team name to it.

Don’t use a struct, use an enum, go on YouTube, and search “ue4 enum”, and you’ll get all the info you need. It’s a list of variables that you can switch based off of that players team. when that player is spawned set a variable that is replicated, and is set to your custom enum, and then do logic based off of that. ie: if enum == blue, then set player color to blue.and Also set a variable in player state, so the server can access it easier. I can send pictures if you need further help

it seems that i need more explanation. i learned how enum works but dont know how to work with it on event OnPostLogin.
when a player joins the game he is already spawned in map (character is selected before) so in joining time the team variable should be determined for the player.
send pictures please

1 Like

I’m currently trying to use enum too for team selection, but is there a way to assign a random player controller to the enum?

What do you mean by assigning the player controller to the enum?