Verse Library verse

01 Device

Spawns a cannon at a set location when players interact with the dispenser device.

verse-library/cannon-spawner-device-design-examples-in-fortnite/01-device.verse

# CannonDispenser.ver
# A script that spawns a cannon when a player interacts with a button.

using { /Fortnite.com/Devices }
using { /VerseOrg/Simulation }
using { /UnrealEngine.com/Temporary/Symbols as EngineSymbols }

# 1. Define the Device Structure
# This tells Verse: "This script belongs to a specific device in the editor."
# Think of this as the 'class' definition, but attached to the physical device.
CannonDispenserDevice := class(creative_device):

    # 2. Define Variables (The "Stats" of our device)
    # SpawnPoint: The exact location where the cannon will appear.
    # We link this to a 'Point Light' or 'Target' in the editor.
    SpawnPoint := property(creative_object, writable):
        pass

    # CannonSpawnerRef: The actual Cannon Spawner device we want to activate.
    # We link this to the 'Cannon Spawner' device in the editor.
    CannonSpawner := property(creative_device, writable):
        pass

    # 3. The Event: What happens when someone clicks the button?
    # 'OnInteracted' is a built-in event. It fires when a player presses 'Interact' on this device.
    # It’s like the 'Storm Timer' finishing—something happened, now react.
    OnInteracted(event: creative_interacted_event) -> unit:
        # Check if the player who interacted is actually a player (not an NPC or glitch)
        if (player := event.Get_Interacting_player()) != nil:

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