Verse Library verse

02 Standalone

Extends a prop component to automatically hide and show itself after a trigger event.

verse-library/create-a-platformer-with-scene-graph-in-unreal-editor-for-fortnite/02-standalone.verse

using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Temporary/Diagnostics }

# Define the component.
# creative_prop_component gives us Hide() and Show() for the attached prop.
DisappearingPlatformLogic := class(creative_prop_component):
    # How long to wait before disappearing (seconds).
    @editable
    Delay : float = 1.5

    # This runs when the component starts.
    OnBegin<override>()<suspends> : void =
        # We want to listen for players stepping on this object.
        # We assume the Prefab has a Trigger Device tagged with tag_my_trigger.
        # In the editor, add the tag "tag_my_trigger" to the Trigger device
        # that is placed inside this Prefab.
        if (Trigger := GetCreativeObjectsWithTag(tag_my_trigger{})[0],
            TriggerDevice := trigger_device[Trigger]):
            # This loop waits forever for a trigger event.
            loop:
                # Await fires each time a player steps on the trigger.
                Agent := TriggerDevice.TriggeredEvent.Await()

                # Wait a tiny bit so the player registers the step.
                Sleep(0.1)

                # Hide the platform (invisible + no collision).
                Hide()

                # Wait our set time before bringing it back.

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