using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /Verse.org/Random } # We are creating a device that listens for players. # 'creative_device' is the base class for all UEFN devices. # Think of it as the "container" for our logic. platform_trap := class(creative_device): # --- VARIABLES (The Loot Drops) --- # This is the platform prop we want to hide. # @editable means you can change this in the editor's Details panel. @editable GhostPlatform: creative_prop = creative_prop{} # This is the trigger zone we are attaching to. @editable TouchSensor: trigger_device = trigger_device{} # The big one: How many seconds to wait after landing? # We default to 2.0 seconds. Change this in the editor! @editable DisappearDelay: float = 2.0 # --- THE BRAIN (OnBegin) --- # This function runs once when the game starts. # means this function can pause and wait. OnBegin(): void = # Subscribe to the TriggeredEvent. # This is like setting up a security camera. # Whenever the TouchSensor is tripped, run the 'HandleTouch' function. TouchSensor.TriggeredEvent.Subscribe(OnTouch) # We don't return anything, so it's 'void'. # The code here just sets up the listener and then stops. # The actual waiting happens inside HandleTouch. # This function runs EVERY TIME someone lands on the platform. OnTouch(Agent: ?agent): void = spawn { HandleTouch() } HandleTouch(): void = # 1. WAIT! # Pause the execution of THIS specific instance. # The game doesn't freeze; it just waits 'DisappearDelay' seconds. Sleep(DisappearDelay) # 2. VANISH # Hide the mesh. It's still there in the code, but invisible. GhostPlatform.Hide() # 3. REAPPEAR (The Reset) # Wait a random amount of time between 1 and 3 seconds. # This makes the trap feel alive and unpredictable. RandomWait := GetRandomFloat(1.0, 3.0) Sleep(RandomWait) # Show the platform again for the next victim. GhostPlatform.Show()