Verse Library verse

01 Device

Binds a door movement event to open a prop mover device when triggered in the scene.

verse-library/subjects-panel/01-device.verse

# This is our special door device.
# It knows how to move things.
using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Simulation }

# We create a new script called "OpenDoorScript"
# This is the brain of our door.
OpenDoorScript := class(creative_device):

    # This is the Prop Mover device we want to use.
    # We will pick this from the Subjects Panel later!
    @editable
    Door : prop_mover_device = prop_mover_device{}

    # This runs when the game starts.
    OnBegin<override>()<suspends> : void =
        # We wait for a player to get close.
        # This is like waiting for a friend to tie their shoes.
        # Subscribe to the trigger so we know when to open the door.
        Door.BeganEvent.Subscribe(OnDoorTriggered)

    # This runs when the Prop Mover's BeganEvent fires.
    # We call this an "Event."
    OnDoorTriggered() : void =
        # Tell the Prop Mover to begin moving to its target position.
        # The target position is set in the editor properties.
        # This opens the door!
        Door.Begin()

Comments

    Sign in to vote, comment, or suggest an edit. Sign in