Team balancing

Does someone know how team balancing works right now in UEFN? There is an option in the island settings… I also saw an option with verse, but it seems like the code is out of date and does not work anymore

Thanks in advance!

hi @DARICKO ,
The official article is now at
post #4 below the documented code wont work
Use UEFN Feature Sample
Verse - Triad Infiltration - Balancing Teams Asymmetrically

The documentation code has an error
The Verse code in line 36 does not work (Length)

Hi Jimbohalo10!

Thanks for the reply.
I tried this tutorial you linked… The Verse code in line 36 does not work (Length)

hi @DARICKO ,
I have looked into this and found out that UEFN Feature Sample has
Verse - Triad Infiltration - Balancing Teams Asymmetrically

The Verse code in the example has been changed for the latest version of UEFN currently 29.20.

The problems in documentation all relate to fact that the Verse code was for Fortnite 20.10 and has NOT been updated.
Use the UEFN Feature Sample Verse - Triad Infiltration Verse Project code

The Logger.Print is below with log lines highlighted

This documentation for Balancing, DO NOT use this code use UEFN Feature project code
Triad Infiltration | Epic Developer Community (epicgames.com)

Link to Balancing Teams functionality
3. Balancing Teams Asymmetrically | Epic Developer Community (epicgames.com)

Remove quote causing brown highlighting format errors

Open Verse by double clicking on top bar “Verse” in UEFN Screen

hi @DARICKO

Here is another simpler code post
issue. Setting 2 Teams of Random Players? - Programming & Scripting / Verse

Hey @Jimbohalo10 Jimbo! I just stumbled upon your excellency once again!

  • Game is Two Teams, with exception of Team 3 for Team choosing.
  • I am using a “choose your team” at game start (all players spawn on team 3, then choose team 1 or 2)
  • Then Join in progress (45 minute game with join in progress)
  • I need the players to balance for Join in Progress, EXCLUDING team 3.
  • The smaller team will always be team 3 because it is the Game Start assigned team. So I need the exclusion of team 3 in all circumstances maybe with logic statements?
  • The game only needs to balance by spawning players on team 1 or 2, instead of team 3.
  • I wrote out some scripts in Verse but the functionality is a bit unreliable and it does not exclude team 3 from multiplayer balance.
team_multiplayer_balance := class(creative_device):
    # Holds the teams found with GetTeams()
    var Teams: []team = array{}
    
    OnBegin<override>()<suspends>: void =
        Print("Verse Device Started!")
        set Teams = Self.GetPlayspace().GetTeamCollection().GetTeams()
        AllPlayers := GetPlayspace().GetPlayers()
        # Subscribe to PlayerAddedEvent to allow team rebalancing when a new player joins the game
        Self.GetPlayspace().PlayerAddedEvent().Subscribe(OnPlayerAdded)
        Print("Beginning to balance teams")
        BalanceTeams()
    
    # Handles a new player joining the game
    OnPlayerAdded(InPlayer: player): void =
        Print("A new Player joined, assigning them to a team!")
        BalanceTeams()
    
    # Balances teams, excluding Team 3
    BalanceTeams(): void =
        AllPlayers := GetPlayspace().GetPlayers()
        for (TeamPlayer: AllPlayers, CurrentTeam := GetPlayspace().GetTeamCollection().GetTeam[TeamPlayer]):
            # Assign Players to a new team if teams are unbalanced and not Team 3
            var TeamSize: int = 0
            if (set TeamSize = GetPlayspace().GetTeamCollection().GetAgents[CurrentTeam].Length):
                Print("Size of this player's starting team is {TeamSize}")
            
            SmallestTeam: ?team = FindSmallestTeam(TeamSize)
            if (TeamToAssign := SmallestTeam?, GetPlayspace().GetTeamCollection().AddToTeam[TeamPlayer, TeamToAssign]):
                Print("Attempting to assign player to a new team")
    
    FindSmallestTeam(CurrentTeamSize: int): ?team =
        var SmallestTeam: ?team = false
        var TeamSize: int = CurrentTeamSize
        
        # For each team Team, get the number of players on that team. If it has less players than SmallestTeam,
        # set SmallestTeam to Team and update TeamSize to the number of players on the new Team
        for (Team: Teams, CandidateTeamSize := GetPlayspace().GetTeamCollection().GetAgents[Team].Length, TeamSize > CandidateTeamSize):
            # Check if the team is not Team 3
            if (Team = GetPlayspace().GetTeamCollection().GetAgents[Team = 3]):
                set SmallestTeam = option{Team}
                set TeamSize = CandidateTeamSize
                Print("Found a team with less players: {CandidateTeamSize}")
        
        return SmallestTeam

I was curious to know if someone has something similar to this but also provide some functionality with the feedback would be great!

Thank you for all your time. I greatly appreciate it.

1 Like