# TreasureSound.verse # We define our device class. # This holds all our logic and device references. treasure_sound_device := class(creative_device): # The trigger device detects when a player walks in. # Assign your TreasureZone trigger device here in UEFN. @editable TreasureZone : trigger_device = trigger_device{} # The audio player device plays our sound cue. # Assign your Audio Player device here in UEFN. # Set the sound asset on the Audio Player device itself. @editable TreasureAudio : audio_player_device = audio_player_device{} # OnBegin is the main entry point. # It runs once when the island loads. OnBegin() : void = # Connect the trigger's event to our handler function. # This is like telling the guard: watch the door. TreasureZone.TriggeredEvent.Subscribe(OnPlayerEntered) # This function runs when a player enters the zone. # Agent is the player who triggered the zone. OnPlayerEntered(Agent : agent) : void = # Play the sound through the audio player device. # The audio player device uses the sound asset # you assigned to it in the UEFN details panel. TreasureAudio.Play() Print("Player entered the treasure zone!")