Verse Library verse

01 Device

Detects player entry into a trigger and executes logic.

verse-library/using-the-trigger-device-to-start-things-in-your-game/01-device.verse

# This is a simple script for a Trigger device.
# It starts the game when a player steps on it.

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

# This is the main script block.
# Think of it as the brain of the trigger.
trigger_manager := class(creative_device) {

    # Bind a trigger_device from the editor so we can
    # listen to its TriggeredEvent.
    @editable
    MyTrigger : trigger_device = trigger_device{}

    # This line listens for a player.
    # "OnBeginPlay" is the event.
    # It happens when the game starts.
    OnBeginPlay<override>() : void = {
        # Subscribe to the trigger's TriggeredEvent.
        # "TriggeredEvent" fires whenever a player
        # walks into the trigger volume.
        MyTrigger.TriggeredEvent.Subscribe(OnPlayerEntered)
    }

    # This function runs when someone walks in.
    # "Agent" is the Verse type for the entity
    # that activated the trigger.

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