Verse Library verse

01 Device

Listens for player entry into a trigger zone and identifies the character activating it.

verse-library/landscape-splines/01-device.verse

# This is a simple Verse script
# It changes the road color when a player touches it

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

# Our manager class lives on a trigger_device placed at the road.
# In the editor, place a trigger_device and set its name to "My_Road".
road_manager := class(creative_device):

    # Wire this trigger_device to road_manager in the editor.
    # The trigger fires when a player walks into the road zone.
    @editable
    RoadTrigger : trigger_device = trigger_device{}

    # OnBegin runs once when the level starts.
    OnBegin<override>()<suspends> : void =
        # Listen for when a player enters the trigger volume.
        # trigger_device.TriggeredEvent gives us the agent who stepped in.
        RoadTrigger.TriggeredEvent.Subscribe(HandlePlayerEnter)

    # This function handles the event.
    # agent is the character that activated the trigger.
    HandlePlayerEnter(Source : ?agent) : void =
        # Cast agent to fort_character so we can call character functions.
        if (ActualSource := Source?, Character := ActualSource.GetFortCharacter[]):
            # Print a message to the output log so we know it worked.
            # Note: there is no built-in runtime HUD text API in Verse yet;

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