# This script lives on the Island. It finds our devices and listens for triggers.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
MoodSwitcher_Script := class(creative_device):
# 1. Define the devices we want to control.
# Think of these as "handles" to the devices in your level.
# Decorate with @editable so they appear as linkable fields in the UEFN Details panel.
@editable
Instrument_Player : instrument_player_device = instrument_player_device{}
@editable
Trigger : trigger_device = trigger_device{}
# 2. This function runs when the game starts.
# It's like the "Game Start" event in the device menu, but with more power.
OnBegin<override>()<suspends> : void =
# 3. Listen for the trigger being activated.
# When the player hits the trigger, this code runs.
Trigger.TriggeredEvent.Subscribe(OnTriggered)
# 4. This function is called whenever the Trigger fires.
OnTriggered(Agent : agent) : void =
# 5. Change the instrument!
# PlayInstrument tells the Instrument Player device to activate.
# Instrument selection is configured in the device's Details panel in the editor;
# use the device's Play function to start it from Verse.
# note: instrument_player_device exposes Play/Stop but not a runtime string-based
Verse Library
verse
01 Device
Triggers instrument playback and switches audio settings when players activate a trigger device.
verse-library/using-patchwork-instrument-player-devices-in-fortnite-creative/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.