Verse Library verse

01 Standalone

Connects a trigger device to an audio player so sound plays when activated.

verse-library/feedback-sounds/01-standalone.verse

# This script makes sounds play when you hit triggers

# First, we define our devices.
# A 'Device' is any object in your level.
Win_Trigger := struct() {
    Trigger : Trigger_Device
}

Win_Sound := struct() {
    Audio_Player : Audio_Player_Device
}

# This function runs when the game starts.
Main := func() {
    # We connect the Trigger to the Sound.
    # When the Trigger is hit, play the Sound.
    Win_Trigger.Trigger.OnBeginPlay += func() {
        Win_Sound.Audio_Player.Play()
    }
}

Comments

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