Verse Library verse

01 Device

Activates a creature spawner device when a player interacts with a creative button.

verse-library/using-creature-spawner-devices-in-fortnite-creative/01-device.verse

# This is our main script file.
# It connects the button to the spawner.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# We declare our device class, which holds references
# to the devices we placed in the editor.
monster_squad_device := class(creative_device):

    # These @editable fields let us drag our placed
    # devices into the script from the UEFN Details panel.
    @editable
    CreatureSpawner : creature_spawner_device = creature_spawner_device{}

    @editable
    Button : button_device = button_device{}

    # OnBegin runs automatically when the game starts.
    # We use it to connect the Button to our function.
    OnBegin<override>()<suspends> : void =
        # Now we connect the Button to the function.
        # When the button is pressed, we run StartSpawning.
        Button.InteractedWithEvent.Subscribe(StartSpawning)

    # We define a function called StartSpawning.
    # A function is a reusable block of code.
    # It receives the agent (player) who pressed the button.
    StartSpawning(Agent : agent) : void =

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