using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
# This is our main script.
# It connects the coin to the reward.
MyCollectibleScript := class(creative_device):
# Bind MyCoin in the UEFN editor by selecting this device
# and assigning the Collectible Object to this property.
@editable
MyCoin : collectible_object_device = collectible_object_device{}
# Bind MyRewards in the UEFN editor by selecting this device
# and assigning the Item Granter to this property.
@editable
MyRewards : item_granter_device = item_granter_device{}
# This part runs when the game starts.
OnBegin<override>()<suspends>: void=
# We listen for when the coin is picked up.
# 'MyCoin' must be assigned in your editor's Details panel.
MyCoin.CollectedEvent.Subscribe(OnCoinPicked)
Print("Coin is ready! Go get it!")
# This function runs when the coin is picked.
# CollectedEvent sends the agent (player) who picked it up.
OnCoinPicked(Collector : agent): void=
# Give the player their reward via the Item Granter.
# The Item Granter device grants whichever item
Verse Library
verse
01 Device
Triggers an item granter to grant rewards to players when they collect a specific coin object.
verse-library/using-collectibles-object-devices-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.