Verse Library verse

01 Device

Subscribes to spawn pad events to initialize and display player characters on join.

verse-library/build-the-play-area/01-device.verse

# This is a simple Verse script for a spawn pad.
# It runs when a player starts the game.

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

# This is a Device. It is a game object.
# We attach this script to a Player Spawn Pad.

spawn_pad_device := class(creative_device):

    # Reference to the player_spawner_device placed in the scene.
    # Assign this in the UEFN details panel.
    @editable
    SpawnPad : player_spawner_device = player_spawner_device{}

    # This function runs when the game starts.
    OnBegin<override>()<suspends> : void =
        # Tell the device to wait for players.
        # It will trigger when someone steps on it.
        SpawnPad.SpawnedEvent.Subscribe(SpawnPlayerHandler)

    # This is a handler. It reacts to events.
    # note: SpawnedEvent sends an `agent` argument via its subscribe callback.
    SpawnPlayerHandler(Agent : agent) : void =
        # Give the player a weapon.
        # This makes the game fun immediately.
        # note: Verse has no direct Give_Weapon API; item_granter_device

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