Verse Library verse

01 Device

Frames a sword prop using a cinematic sequence when a player presses a button.

verse-library/composition-techniques/01-device.verse

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

# This is our main script. It watches for button presses.
sword_camera_device := class(creative_device):

    # This is a variable. It remembers the button device object.
    # Think of it like a label on a box.
    @editable
    MyButton : button_device = button_device{}

    # This is the player spawner we will use to find the player.
    @editable
    MySpawner : player_spawner_device = player_spawner_device{}

    # OnBegin runs automatically when the game starts.
    # We use it to connect the button to our function.
    OnBegin<override>()<suspends> : void =
        # Subscribe tells the button: "When clicked, run OnClicked."
        MyButton.InteractedWithEvent.Subscribe(OnClicked)

    # This runs when the button is clicked.
    # Agent is the player who pressed the button.
    OnClicked(Agent : agent) : void =
        # Try to get the Fortnite character from the agent.
        if (Player := player[Agent]):
            if (FortChar := Player.GetFortCharacter[]):
                # Move the camera to frame the sword prop.

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