# We are defining a new Script. Think of this as the "Brain" for our trigger. # It needs to know about the Trigger Volume (trigger_device) and the # specific launcher (launch_pad_device). using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } chaos_trigger := class(creative_device): # This is our "Inventory" of tools. # 'MyLauncher' is a variable that will hold the D-Launcher (crash pad) device. # We mark it as '@editable' so we can drag-and-drop the actual device # from the world into this slot in the editor. @editable MyLauncher : crash_pad_device = crash_pad_device{} # 'MyTrigger' holds the Trigger Volume we want to listen to. @editable MyTrigger : trigger_device = trigger_device{} # This is the main function. It runs once when the island starts. OnBegin() : void = # 2. LISTEN FOR INPUT # We want to know when a player enters the Trigger Volume. # We call the Trigger's "TriggeredEvent" and subscribe to it. # This is like saying: "Hey Trigger, ring this bell every time someone walks in." # We connect that bell to our 'HandlePlayerEnter' function below. MyTrigger.TriggeredEvent.Subscribe(HandlePlayerEnter) # This function runs EVERY TIME a player activates the trigger. # trigger_device fires TriggeredEvent with an optional agent (?agent). HandlePlayerEnter(MaybeAgent : ?agent) : void = # 3. EXECUTE THE CHAOS # Unwrap the optional agent before using it. if (Agent := MaybeAgent?): # Cast the agent to a fort_character so we can interact with them. if (FortCharacter := Agent.GetFortCharacter[]): # Launch the player! # crash_pad_device has no direct Launch(agent) method; # we just enable/disable to trigger the pad's built-in launch for nearby players. MyLauncher.Enable() # Optional: print a message to the player's HUD. if (Player := player[Agent]): Print("BOING! You've been launched!", ?Duration := 3.0)