Verse Library verse

03 Device

Subscribes to player jump events to award points via a score manager for a hops minigame.

verse-library/verse-char-events/03-device.verse

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

# REACTING TO THE PLAYER — listen to what the character DOES.
#
# A fort_character doesn't just sit there to be read and pushed; it BROADCASTS.
# Every time the player jumps, crouches, sprints, or gets eliminated, the
# character fires an event you can subscribe to. That's how you build reactive
# islands: a sound when they jump, a score when they sprint past a line, a
# respawn when they're eliminated. This device awards a point each time a
# player jumps — a "hops counter" minigame, no trigger volumes required.
char_hop_counter_device := class(creative_device):

    # Optional scoreboard to bump on each jump.
    @editable
    HopScore : score_manager_device = score_manager_device{}

    OnBegin<override>()<suspends> : void =
        # When a player joins, hook up their character's events. We do the
        # existing players now, and also catch anyone who joins later.
        Playspace := GetPlayspace()
        for (P : Playspace.GetPlayers()):
            HookUp(P)
        Playspace.PlayerAddedEvent().Subscribe(HookUp)

    # Wire one player's character events. Called per player.
    HookUp(P : player) : void =

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