Verse Library verse

01 Fragment

Creates a timed trapdoor that opens when triggered, drops players, and resets after a cooldown.

verse-library/get-started-creating-in-fortnite/01-fragment.verse

// Define the script. This is the blueprint for our trap.
struct RevengeTrapScript(Owner: Entity) is init
{
    // VARIABLE: 'IsTrapActive' is a boolean (True/False).
    // Think of it like a light switch. It's either ON or OFF.
    IsTrapActive: bool = true

    // FUNCTION: 'TriggerTrap' is our combo move.
    // It takes no inputs and returns nothing (void).
    TriggerTrap() -> void
    {
        // Check if the trap is currently active (the light switch is ON).
        if (IsTrapActive)
        {
            // 1. Set the switch to OFF so it doesn't trigger again immediately.
            IsTrapActive = false

            // 2. Get the owner entity (the trapdoor itself).
            // We use 'Owner' to tell the game which specific prop to move.
            TrapDoor := Owner

            // 3. Move the trapdoor down by 500 units (into the pit).
            // This is like pressing 'Down' on the D-pad for the Prop Mover.
            TrapDoor.SetLocation(TrapDoor.GetLocation() + <0, 0, -500>)

            // 4. Wait for 2 seconds (the cooldown).
            // During this time, the player falls into the pit.
            Sleep(2.0)

            // 5. Reset the trap! Move it back up.

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