Verse Library verse

01 Fragment

Detects player entry into a trigger volume and handles the event with location logging and knockback logic.

verse-library/using-cabin-galleries-in-fortnite-creative/01-fragment.verse

# This is the main structure of our script.
# Think of this as the "Blueprint" for our trap.
script class CabinTrapScript: Scriptable

    # This is a "Variable". 
    # In game terms, it's like a backpack slot. 
    # We are saving a reference to our Trigger Volume here.
    # We'll fill this in the editor later.
    TrapTrigger: TriggerVolume = TriggerVolume{}

    # This is a "Function". 
    # It's a set of instructions that happens when something calls it.
    # Here, it's called "OnBegin", which means "When the game starts".
    OnBegin() -> void:
        # We need to tell the trigger to listen for players.
        # This is like setting up a tripwire.
        # When a player enters the TriggerVolume, it fires an "Event".
        # We connect our "HandlePlayerEntry" function to that event.
        TrapTrigger.PlayerEntered += HandlePlayerEntry

    # This is another Function. 
    # It runs ONLY when a player enters the trigger.
    HandlePlayerEntry(Player: Player) -> void:
        # Let's make it fun. We knock the player back.
        # This is the "Output" of our event.
        
        # Get the player's current location
        PlayerLocation := Player.GetLocation()
        
        # Apply a force to knock them back (simulated by moving them)

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