// This is a simple Verse script to help us understand the logic. // In UEFN, we mostly use the Visual Scripting or Widget Editor. // But here is how the data flows in Verse. using { /Fortnite.com/Devices } using { /Fortnite.com/UI } using { /Fortnite.com/Characters } using { /UnrealEngine.com/Temporary/UI } using { /Verse.org/Simulation } # This is our main device. It holds our UI. PlayerAvatarDevice := class(creative_device): # This function runs when the game starts. OnBegin(): void = # Get all players currently on the island. AllPlayers := GetPlayspace().GetPlayers() # Loop over every player and show their avatar UI. for (Player : AllPlayers): ShowAvatarUI(Player) Print("Avatar shown!") # Helper function: build and display the avatar widget for one player. ShowAvatarUI(Player : player): void = # GetFortCharacter[] fails if the player has no character yet, # so we use 'if' to safely unwrap the optional result. if (FortChar := Player.GetFortCharacter[]): # Create a simple text widget as a stand-in for the avatar icon. # note: Verse has no built-in PlayerAvatarIcon widget at runtime; # the real avatar image binding is done in the UEFN Widget Editor # using the HUDPlayerInfoViewModel Brush binding (see tutorial body). AvatarLabel := text_block: DefaultText := "Avatar: {FortChar.GetDisplayName()}" # note: GetDisplayName() returns the player's display name string. # Wrap the label in a canvas so it can be positioned on screen. AvatarCanvas := canvas: Slots := array: canvas_slot: Widget := AvatarLabel Anchors := anchors: Minimum := vector2{X := 0.05, Y := 0.05} Maximum := vector2{X := 0.05, Y := 0.05} Offsets := margin{Top := 0.0, Left := 0.0, Bottom := 0.0, Right := 0.0} Alignment := vector2{X := 0.0, Y := 0.0} SizeToContent := true # Add the widget to this specific player's HUD. if (PlayerUI := GetPlayerUI[Player]): PlayerUI.AddWidget(AvatarCanvas)