Verse Library verse

01 Fragment

Hides a trap mesh until a player enters its detection radius, then triggers activation logic.

verse-library/material-properties/01-fragment.verse

# Import the necessary Verse modules for interacting with the world
import CoreGame from "CoreGame"
import Game from "Game"

# Define our custom Trap Class
# This is like creating a new blueprint in UEFN
class RevengeTrap is CoreGame.AActor {
    # 1. Variables (The "Inventory Slots")
    # We need a reference to the visual part of our trap (the mesh)
    VisibleMesh: CoreGame.StaticMeshComponent = CoreGame.StaticMeshComponent{}
    
    # A variable to track if the trap is active (like a health bar)
    IsTriggered: bool = false
    
    # The distance at which the trap becomes visible (like trigger radius)
    DetectionRadius: float = 500.0

    # 2. OnBeginPlay (The "Loadout" Phase)
    # This runs once when the game starts
    OnBeginPlay() -> void override {
        super.OnBeginPlay()
        
        # Make sure we have a mesh to modify
        if (VisibleMesh != null) {
            # Set the initial state: INVISIBLE
            # We use SetMaterial to change the material properties
            # Think of this as equipping a "Stealth Skin"
            SetInvisibleMaterial()
        }
    }

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