using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # TRIGGERED SFX: play a sound the instant a player steps onto a pad. # # Wire a Trigger Device (the entry pad) and an Audio Player Device (the # stinger) into the slots below. Each time someone enters the trigger zone, # we fire the sound effect — the audio "doorbell" of your nightclub entrance, # a whoosh as a player crosses the dance floor, a coin chime on a tile. triggered_sfx_device := class(creative_device): # The zone that detects a player stepping in. @editable EntryPad : trigger_device = trigger_device{} # The one-shot sound effect to fire on entry. @editable StingerSfx : audio_player_device = audio_player_device{} OnBegin() : void = StingerSfx.Enable() # Handle one entry per loop iteration, forever. loop: # Block here until someone steps into the pad. The event sends the # ?agent that triggered it (false if it was fired by code). MaybeAgent := EntryPad.TriggeredEvent.Await() if (Agent := MaybeAgent?): # Heard-by-instigator setups can play just for that player. StingerSfx.Play(Agent) else: # No agent (code-triggered) — play for everyone nearby. StingerSfx.Play() Print("Entry stinger fired")