# 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<override>()<suspends> : 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[]):
Verse Library
verse
01 Device
Detects player entry in a trigger volume, casts to Fort Character for further interaction.
verse-library/using-explosive-consumables-in-fortnite-creative/01-device.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.