Verse Library verse

02 Device

Tracks collected coins via trigger events, updates progress, and declares victory at completion.

verse-library/build-your-own-lego-obstacle-course-in-fortnite-creative/02-device.verse

# If you only want ONE large trigger zone instead of five individual coins,
    # replace the CoinTriggers array with a single trigger_device field.

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

    obby_manager_simple := class(creative_device):

        @editable
        CoinTrigger : trigger_device = trigger_device{}

        var CoinCount : int = 0
        TotalCoins : int = 5

        OnBegin<override>()<suspends> : void =
            # Subscribe once to the single zone trigger
            CoinTrigger.TriggeredEvent.Subscribe(OnCoinCollected)

        OnCoinCollected(Agent : agent) : void =
            set CoinCount += 1
            Print("Coin Collected! Total: {CoinCount}")

            if (CoinCount = TotalCoins):
                Print("YOU WIN!")

Comments

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