using { /Verse.org/SceneGraph }
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
# This is our main script.
# It attaches to an entity in your level.
MyDoorScript := class(creative_device):
# This is the sound component.
# It is the "tool" that makes noise.
# Assign a sound asset to this in the UEFN editor's Details panel.
@editable
SoundComp: audio_player_device = audio_player_device{}
# This is the trigger device.
# It detects when a player touches the door.
# Place a trigger_device in your level and wire it here.
@editable
Trigger: trigger_device = trigger_device{}
# This function runs when the game starts.
OnBegin<override>()<suspends>: void =
# Connect the trigger to our sound.
# When the trigger fires, play the sound.
Trigger.TriggeredEvent.Subscribe(OnDoorTriggered)
# This function plays the sound.
# agent? is the optional agent (player) that activated the trigger.
OnDoorTriggered(Source: ?agent): void =
# Play the sound attached to the component.
Verse Library
verse
01 Device
Plays audio assets when players interact with level triggers or proximity sensors.
verse-library/adding-audio-music-and-sound-effects-with-verse/01-device.verse
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.