Verse Library verse

01 Device

Device using a trigger to detect player overlap and swap prop visuals or activate material effects.

verse-library/edit-material-instances/01-device.verse

# This is a simple Verse script.
# It changes a prop's color when you touch it.

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

# We define a device called "GlowingProp".
# This device holds our prop and its material.
GlowingProp := class(creative_device):
    # This is the prop we want to change.
    # Wire this to a creative_prop in the editor.
    @editable
    Prop : creative_prop = creative_prop{}

    # This is the trigger we use to detect a player touching the prop.
    # Place a trigger device around the prop in the editor and wire it here.
    # note: Verse has no direct per-prop touch API; a trigger_device is the
    #       standard way to detect a player entering a prop's area.
    @editable
    TouchTrigger : trigger_device = trigger_device{}

    # OnBegin runs when the game starts.
    OnBegin<override>()<suspends> : void =
        # Subscribe to the trigger's Triggered event.
        # When a player walks into the trigger, OnPropTouched fires.
        TouchTrigger.TriggeredEvent.Subscribe(OnPropTouched)

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