Verse Library verse

02 Device

Implements a Radio Device class that registers players on join and manages looping background music playback.

verse-library/verse-sound-music-loops/02-device.verse

using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# MUSIC & LOOPS: pump looping music onto the dance floor for every player.
#
# A Radio Device is built for curated, looping music. The pattern is different
# from a one-shot SFX: you REGISTER the agents who should hear it, then Play().
# Here we register every player as they join, so the whole club hears the set,
# and we Stop() cleanly if we ever need silence (an intermission, a boss line).
music_loop_device := class(creative_device):

    # Wire a placed Radio Device here.
    @editable
    DanceFloorRadio : radio_device = radio_device{}

    OnBegin<override>()<suspends> : void =
        # Register everyone already in the match, then start the music.
        Players := GetPlayspace().GetPlayers()
        for (Player : Players):
            DanceFloorRadio.Register(Player)
        DanceFloorRadio.Play()
        Print("Dance floor music started")

    # Call this to register a late-joiner so they hear the set too.
    AddListener(Player : agent) : void =
        DanceFloorRadio.Register(Player)

    # Drop the beat — silence the whole floor (e.g. for an announcement).

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