using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Temporary/Symbols }
# Define our Component.
# 'Device' is the interface that lets this script talk to a Button device.
ChaosButton := device (
# This is the input from the physical button in the editor
ButtonPressed: input <button_pressed_event>,
# This is the output we'll use to trigger effects (like spawning)
# For this demo, we'll just use a simple output to trigger a sound or effect
# But we'll handle the logic inside.
EffectTriggered: output <void>
)
# The main logic function.
# 'OnAdded' is called once when the game starts and this device is loaded.
OnAdded := func (): void:
# Listen for the button being pressed
# 'Bind' connects the physical button input to our function
ButtonPressed.Bind(func (event: button_pressed_event): void:
# This runs every time the button is clicked!
SpawnChaos()
)
# Our custom function to handle the chaos
SpawnChaos := func (): void:
# Get the location of this device
# We use 'GetTransform' to find where we are in the world
SelfTransform := GetTransform()
Verse Library
verse
02 Fragment
Creates a button device that triggers a custom chaos-spawning function when pressed by players.
verse-library/creating/02-fragment.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.