Verse Library verse

01 Fragment

Manages player detection events and a nervous timer to change the stealth cardboard state.

verse-library/using-creepin-cardboard-devices-in-fortnite-creative/01-fragment.verse

# This script makes the Creepin' Cardboard react when players hide or exit.

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

# We define a struct (a custom data container) to hold our settings.
# Think of this like a "Device Option" panel, but in code.
struct NervousCardboardOptions {
    GlowColor: linear color = linear color(1.0, 0.0, 0.0) # Red glow
    TimerDuration: float = 5.0 # Seconds before the box gets "nervous"
}

# This is the main script class. It attaches to our Creepin' Cardboard device.
NervousCardboard = script(creepin_cardboard_device):
    # These are "Events" — things that happen in the game world.
    # We don't call these; the game engine calls them for us.
    # OnPlayerEntered is like a "Trigger" in the device menu, but coded.
    OnPlayerEntered: event(player: player)
    OnPlayerExited: event(player: player)

    # A variable to track how long the player has been inside.
    # Think of this like a "Storm Timer" that counts up instead of down.
    HideTimer: float = 0.0

    # A reference to the box itself, so we can change its appearance.
    # In the Scene Graph, this is the "Parent" entity.
    BoxEntity: entity = GetEntity()

    # This function runs every frame (60 times a second).

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