Verse Library verse

01 Device

Plays a sound effect specifically when a valid player enters a zone.

verse-library/using-audio-player-devices-in-fortnite-creative/01-device.verse

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Verse.org/Native }

# Create a new Device called "ChaosTile"
# This device will be placed in the world like a prop or trap
ChaosTile := class(creative_device):

    # This is our "Variable" for the sound.
    # Think of this like a slot in your inventory where you drag your audio file.
    # In UEFN, this appears in the Customize panel.
    @editable
    ChaosSound: audio_player_device = audio_player_device{}

    # This is the "Trigger Zone."
    # Imagine an invisible bubble around the tile.
    @editable
    TriggerZone: trigger_device = trigger_device{}

    # This is the "Event Handler."
    # When a player enters the TriggerZone, this function runs.
    # It's like a motion sensor on a security camera.
    OnPlayerEnter(Agent: ?agent): void =
        # Check if the thing that entered is actually a player
        if (A := Agent?, Player := player[A]):
            # Play the sound!
            # This is like hitting the "Play" button on a remote.
            ChaosSound.Play()

            # Optional: Give them a point or a notification

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