Verse Library verse

02 Device

Listens for collectible pickups and updates a global player score variable.

verse-library/using-collectible-object-devices-in-fortnite-creative/02-device.verse

# Advanced LootGoblin.verse
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

LootGoblin := class(creative_device):

    # A reference to the Collectible Object device in the scene.
    # Drag your Collectible Object into this slot in the Verse panel.
    @editable
    CollectibleDevice : collectible_object_device = collectible_object_device{}

    # A reference to another device in the scene.
    # This is like a remote control pointed at the Item Granter.
    # Drag your Item Granter device into this slot in the Verse panel.
    @editable
    MyGranter : item_granter_device = item_granter_device{}

    # 'var' makes PlayerScore mutable so we can update it during gameplay.
    var PlayerScore : int = 0

    OnBegin<override>()<suspends> : void =
        # Wire the collectible's built-in event to our handler function.
        # Subscribe takes a function that matches the event's signature.
        CollectibleDevice.PickedUpEvent.Subscribe(OnCollectiblePickedUp)
        Print("System Online. Collectibles active.")

    # This handler is called automatically by PickedUpEvent.
    # 'agent' is the Verse type for any participant in the simulation,
    # which includes players. Use it to target per-player devices.

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.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in