using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /Verse.org/Concurrency } # This is our main script. It inherits from creative_device, # which means it can sit in the world as a placed device. scream_trap_device := class(creative_device): # This is our 'Backpack' (Component) that will hold the audio. # audio_player_device is a real UEFN device you place on your island # and wire up in the editor. It wraps your imported sound asset. # Drag an Audio Player Device from the device list onto your island, # then assign it to this slot in the Verse Device details panel. @editable AudioPlayer : audio_player_device = audio_player_device{} # This is our trigger — the pressure plate the player walks over. # Place a Trigger Device on your island and assign it here. @editable Trap : trigger_device = trigger_device{} # This function runs ONCE when the island starts. # Think of this as the 'Pre-Match Lobby' phase. OnBegin() : void = # Subscribe to the trigger's TriggeredEvent. # Whenever a player steps on the Trap, TriggerSound is called. # This is like the Bus picking up the playlist before the drop. Trap.TriggeredEvent.Subscribe(OnTrapped) # This function runs when a player steps on the trigger. # The agent parameter is the player who activated the trap. OnTrapped(Agent : ?agent) : void = # Tell the AudioPlayer device to play its assigned sound asset. # The sound asset itself is configured on the audio_player_device # in the UEFN editor — set it to your imported ScreamSample there. # This is the 'Drop'. Instant playback. AudioPlayer.Play() # To make this work in UEFN, you: # 1. Place a 'Verse Device' on your island and assign this class to it. # 2. Place an 'Audio Player Device' and assign your ScreamSample asset to it # via that device's Sound property in the Details panel. # 3. Place a 'Trigger Device' where you want the pressure plate. # 4. In the Verse Device Details panel, drag the Audio Player Device into # 'AudioPlayer' and the Trigger Device into 'Trap'. # No manual editor wiring needed — the Subscribe call handles the connection.