Verse Library verse

01 Standalone

Swaps a floor material to a ghost effect when a player steps on it.

verse-library/material-blend-modes/01-standalone.verse

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

# 1. Define our Device
DangerTrapDevice = class(ForgeDevice):

    # 2. Variables (The "Stats" of our trap)
    var trap_floor: StaticMeshActor = actor:StaticMeshActor
    var normal_material: Material = asset:"/Game/Materials/M_Normal_Floor.M_Normal_Floor"
    var ghost_material: Material = asset:"/Game/Materials/M_Danger_Ghost.M_Danger_Ghost"
    
    # 3. The "When I get touched" Event
    OnBeginOverlap := func(other: Actor): void:
        # Check if the thing touching us is a Player
        if player := other:AsFortnitePlayer():
            
            # 4. The "Magic" - Swap the Material
            # We are telling the StaticMeshActor to use the new material
            trap_floor:Material = ghost_material
            
            # Optional: Play a sound or change color here
            # print("Player stepped on the ghost trap!")

    # 5. The "When I start" Event (Setup)
    OnBegin<override>() := func(): void:
        # Ensure the trap starts as normal
        trap_floor:Material = normal_material

Comments

    Sign in to vote, comment, or suggest an edit. Sign in