# We are creating a simple script that manages a particle effect. # In a real UEFN project, you'd attach this to a Device. using { /Fortnite.com/Devices } using { /Verse.org/Simulation } # This is our "Device" — the thing you place in the world. # Think of it like a Trap or a Prop-Mover. test_device := class(creative_device): # We need a reference to the VFX Spawner device we place in the editor. # In UEFN, use a vfx_spawner_device (found in the Creative device library) # and assign it here via the Details panel. @editable Emitter: vfx_spawner_device = vfx_spawner_device{} # We need a reference to the Trigger device that detects players. # Place a trigger_device on your island and assign it in the Details panel. @editable Trigger: trigger_device = trigger_device{} # This runs once when the game starts. OnBegin(): void = # Connect our trigger to a function. # When a player enters the zone, run 'OnPlayerEnter'. # TriggeredEvent fires when any agent (player) activates the trigger. Trigger.TriggeredEvent.Subscribe(OnPlayerEnter) # This is the event handler. # 'Agent' is the person who walked into the zone. OnPlayerEnter(Agent: ?agent): void = # 1. SPAWN THE PARTICLE # We tell the VFX Spawner to play its effect. # This is like pressing the "Fire" button on a weapon. # The emitter's Niagara asset is chosen in the editor Details panel — # pick your "SpookySwirl" Niagara System there before pressing Play. Emitter.Enable() # 2. CONFIGURE THE UPDATE (The Magic Part) # In Verse, particle update module values (Drag, Curl Noise strength, # etc.) are authored directly inside the Niagara System in the editor. # At runtime we choose *which* pre-configured vfx_spawner_device fires. # # For this tutorial we have two vfx_spawner_device objects placed on # the island and wired up in the Details panel: # - HeavySmoke (Niagara asset: high Drag, no Curl Noise) # - SpookySwirl (Niagara asset: low Drag, high Curl Noise) # # By calling Emitter.Enable() above we are already using the # "SpookySwirl" device, which has these Niagara module values baked in: # Drag: 0.2 (floats easily) # Curl Noise: 500 (swirls violently) # 3. WAIT AND CLEAN UP # Don't let the particles pile up forever. # Wait 5 seconds (their lifetime), then stop the emitter. # We spawn a new async coroutine so Sleep is allowed here. spawn{ WaitAndDisable() } # Waits 5 seconds then disables the emitter. # Runs as its own coroutine so Sleep is permitted. WaitAndDisable(): void = Sleep(5.0) # Disable the spawner so it stops emitting new particles. # Existing particles finish their own lifetime naturally. Emitter.Disable()