using { /Fortnite.com/Game } using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } # This is our main Game Mode. Think of it as the "Game Master" script. squad_view_manager := class(creative_device): # A reference to the UI Control Device that shows our WBP_SquadView widget. # Wire this up in the UEFN level editor Details panel. @editable SquadUIDevice : hud_controller_device = hud_controller_device{} # This function runs when the game starts. # Think of this as the "Bus Ride" start phase. OnBegin() : void = # 1. Get all players currently in the session. Players := GetPlayspace().GetPlayers() # 2. Listen for when players are eliminated so we can react. # This is like a "Trigger" that fires when someone steps on it. for (Player : Players): ListenForPlayerEliminated(Player) # 3. Show the squad UI widget for every player via the HUD controller device. for (Player : Players): SquadUIDevice.Enable() # A helper function that listens for a single player's elimination event. ListenForPlayerEliminated(Player : agent) : void = # Fort characters expose an EliminatedEvent we can await. # When this event fires it calls our OnPlayerEliminated logic. if (FortCharacter := Player.GetFortCharacter[]): FortCharacter.EliminatedEvent().Await() OnPlayerEliminated(Player) # This runs whenever a teammate is eliminated. OnPlayerEliminated(Player : agent) : void = # Log a message to the output log (like debug text in the bottom left). Print("Teammate eliminated") # Hide the squad UI for the eliminated player so their screen # is no longer cluttered while they spectate. SquadUIDevice.Disable()