Verse Library verse

01 Device

Displays avatar UI widgets for all connected players when the game begins.

verse-library/player-avatar-icon/01-device.verse

// 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<override>()<suspends>: 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.

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

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