Verse Library verse

04 Setting Up Player Join Functions

Assigns joining players to teams, respawns them, and handles team logic.

extracted-snippets/documentation/en-us/fortnite/triad-infiltration-07-balancing-players-during-the-game-in-verse/04-setting-up-player-join-functions.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/triad-infiltration-07-balancing-players-during-the-game-in-verse
# Local doc:  epic-docs/documentation/en-us/fortnite/triad-infiltration-07-balancing-players-during-the-game-in-verse.md
# Section:    Setting Up Player Join Functions
# Handles a new player joining the game.
OnPlayerAdded(InPlayer:player):void=
Logger.Print("A new Player joined, assigning them to a team")
FortTeamCollection := GetPlayspace().GetTeamCollection()
# Assign the new player to the smallest team, asymmetrically.
BalancePlayer(InPlayer)
for:
TeamIndex -> PlayerTeam:Teams
PlayerTeam = FortTeamCollection.GetTeam[InPlayer]
TeamTeleporter := Teleporters[TeamIndex]
Transform := TeamTeleporter.GetTransform()
do:
InPlayer.Respawn(Transform.Translation, Transform.Rotation)
Logger.Print("Teleported the spawned player to their start location")
# If the player was an infiltrator, call OnInfiltratorJoined in
# InvisibilityManager.
if(PlayerTeam = MaybeInfiltrators?):
InvisibilityManager.OnInfiltratorJoined(InPlayer)

Comments

    Sign in to vote, comment, or suggest an edit. Sign in