Verse Library verse

01 Device

Plays an assigned audio cue when an agent enters a linked trigger device zone.

verse-library/audio/01-device.verse

# This is our main script.
# It runs when the island starts.
# We use a creative_device class to hold our devices and assets.
treasure_sound_device := class(creative_device):

    # We reference the trigger_device placed in UEFN.
    # Drag your TreasureZone trigger device here in the details panel.
    @editable
    TreasureZone : trigger_device = trigger_device{}

    # We reference the audio_player_device placed in UEFN.
    # Drag your Audio Player device here in the details panel.
    # The Audio Player device has a sound asset assigned to it.
    @editable
    TreasureAudio : audio_player_device = audio_player_device{}

    # OnBegin runs once when the island starts.
    # It is like turning on the lights.
    OnBegin<override>()<suspends> : void =
        # Tell the console the script is ready.
        Print("Sound system ready!")

        # Connect to the TriggeredEvent on the trigger device.
        # This runs our function when a player enters the zone.
        TreasureZone.TriggeredEvent.Subscribe(OnZoneEntered)

    # This function runs every time a player enters the zone.
    # 'Agent' is the player who walked in.
    OnZoneEntered(Agent : ?agent) : void =
        # Play the sound through the audio player device.

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