Verse Library verse

01 Device

Defines a creative device that initializes on game start and listens for player triggers.

verse-library/create-your-own-device-in-verse/01-device.verse

# This is a simple Verse script for a device.
# It says hello when a player enters its zone.

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

# This is the main class for our device.
# Think of it as the robot's body.
my_hello_device := class(creative_device):

    # A trigger_device is wired in the editor to detect when
    # a player walks into its zone.
    # note: wire this to a Trigger Device placed near your Verse device in UEFN.
    @editable
    Trigger : trigger_device = trigger_device{}

    # This runs once when the game starts.
    OnBegin<override>()<suspends>: void=
        # We print a message to the log.
        # This helps us know the code is running.
        Print("My device is ready!")

        # Subscribe to the trigger so we know when a player enters.
        Trigger.TriggeredEvent.Subscribe(OnTriggered)

    # This runs when a player enters the trigger zone.
    # 'Agent' is the player who touched it.
    OnTriggered(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