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() : 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 = if (Body := P.GetFortCharacter[]): # JumpedEvent fires every time this character jumps. Its payload is # the fort_character that jumped, so one handler serves everyone. Body.JumpedEvent().Subscribe(OnJumped) Print("Listening for jumps on a player") # Fires whenever a subscribed character jumps. OnJumped(Jumper : fort_character) : void = # The event hands us the fort_character. To talk to score/team APIs we # need its agent — GetAgent bridges back. It can fail, so we guard it. if (Who := Jumper.GetAgent[]): HopScore.Activate(Who) Print("A player hopped — point awarded")