# We need access to the Simulation library to use Sleep, # and World to spawn our loot. using { /Verse.org/Simulation } using { /Verse.org/Native } using { /UnrealEngine.com/Temporary/Diagnostics } using { /Fortnite.com/Devices } # This is our "Loot Goblin" component. # It attaches to a Button device and waits to spawn a crate. # # HOW TO SET UP IN UEFN: # 1. Place a button_device in your level. # 2. Place a prop_mover_device in your level; set its # initial state so the crate is hidden off to the side. # 3. Select the button_device, click Add -> New Verse Component, # and choose this file. # 4. In the component's Details panel, drag your prop_mover_device # into the TargetProp slot. loot_goblin_component := class(creative_device): # Editable reference: drag your PropMover into this slot # in the UEFN Details panel. @editable TargetProp : prop_mover_device = prop_mover_device{} # Editable reference: drag your Button device into this slot. @editable LootButton : button_device = button_device{} # OnBegin wires up the button's InteractedWithEvent so we # respond whenever any player presses it. OnBegin() : void = LootButton.InteractedWithEvent.Subscribe(OnButtonPressed) # When the button is pressed, this function fires. # Think of this as the "Trigger" on a trap. # lets us call Sleep without freezing the game. OnButtonPressed(Agent : agent) : void = spawn: WaitThenSpawnLoot() WaitThenSpawnLoot() : void = # 1. Tell the player something is happening. # Print acts like a chat message or system notification. Print("Loot is coming... get ready!") # 2. The Magic Pause. # We tell the simulation to wait 5.0 seconds. # The game does NOT freeze. Other players can still move. Sleep(5.0) # 3. After the 5 seconds are up, activate the PropMover. # The PropMover should be configured in UEFN to move # the crate into its visible, final position when activated. TargetProp.Activate() # 4. Let the player know the loot is here. Print("Loot dropped! Go get it!")