# This is a comment. It explains the code. # We are making a script that works with a Trigger Volume. using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our main script. # It "owns" the Trigger Volume device. explosive_trap_device := class(creative_device): # This is the Trigger Volume device placed on your island. # Link this slot to your Trigger Volume in the editor. @editable MyTrigger : trigger_device = trigger_device{} # OnBegin runs automatically when the game starts. # We use it to connect our function to the trigger's event. OnBegin() : void = # Subscribe tells the trigger: "Call OnPlayerEntered # every time a player walks into the volume." MyTrigger.TriggeredEvent.Subscribe(OnPlayerEntered) # This function runs when a player enters the trigger. # 'Agent' is the person who walked in. OnPlayerEntered(Agent : ?agent) : void = # Cast the agent to a fort_character so we can # interact with them as a Fortnite player character. if (ActualAgent := Agent?, Character := ActualAgent.GetFortCharacter[]): # Consumable granting is handled through the # item_granter_device in UEFN. Here we just # print a message to confirm the trigger fired. # Wire an item_granter_device to do the actual # item grant (see placement steps below). # note: There is no direct GiveConsumable() API # on fort_character; use item_granter_device instead. Print("Trap triggered! Granting explosive item.")