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(): 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. SoundComp.Play()