using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } using { /Verse.org/SpatialMath } using { /UnrealEngine.com/Temporary/Diagnostics } # CAPSTONE: THE BOUNCE ARENA — find + move + react, wired into one minigame. # # This pulls the whole Characters series together. A Button arms the arena; # from then on every player who JUMPS gets launched skyward (MOVE) and scores # a point (REACT), and any player who falls below a kill-floor is found and # teleported back to safety (FIND + a device-native respawn). No trigger # volumes, no hand-wired pads — the character API does it all from Verse. # # Series skills, combined: # * FIND — GetPlayspace().GetPlayers() -> P.GetFortCharacter[] (Lesson 1) # * MOVE — SetLinearVelocity with a Forward/Left/Up vector3 (Lesson 2) # * REACT — Body.JumpedEvent().Subscribe(...) (Lesson 3) bounce_arena_device := class(creative_device): # Press to arm the arena. @editable ArmButton : button_device = button_device{} # Scoreboard bumped on every bounce. @editable BounceScore : score_manager_device = score_manager_device{} # A Teleporter placed at the safe respawn spot. We hand fallen players to # its Teleport(agent) — cleaner than computing a teleport position by hand. @editable RespawnPad : teleporter_device = teleporter_device{} # Upward launch speed (m/s) applied on each jump. @editable BounceSpeed : float = 18.0 # Height (the Up axis) below which a player counts as "fallen". GetTransform # reports translation on Z here (the engine transform), so we compare to Z. @editable KillFloorZ : float = -500.0 var Armed : logic = false OnBegin() : void = ArmButton.InteractedWithEvent.Subscribe(OnArm) OnArm(Presser : agent) : void = if (not Armed?): set Armed = true Print("Bounce Arena armed") Playspace := GetPlayspace() # Hook the players already here, plus anyone who joins later. for (P : Playspace.GetPlayers()): HookUp(P) Playspace.PlayerAddedEvent().Subscribe(HookUp) # Run the fall-watcher forever in the background. spawn { WatchForFalls() } # REACT: subscribe one player's jump to the bounce reaction. HookUp(P : player) : void = if (Body := P.GetFortCharacter[]): Body.JumpedEvent().Subscribe(OnJumped) # REACT + MOVE: a jump scores a point and punches the jumper upward. OnJumped(Jumper : fort_character) : void = Up := vector3{ Forward := 0.0, Left := 0.0, Up := BounceSpeed } Jumper.SetLinearVelocity(Up) # The event hands us a fort_character; GetAgent bridges back to the # agent the score device wants. It can fail, so we guard it. if (Who := Jumper.GetAgent[]): BounceScore.Activate(Who) Print("Bounce! point awarded") # FIND + respawn: every half-second, catch anyone who has fallen. WatchForFalls() : void = loop: Sleep(0.5) for (P : GetPlayspace().GetPlayers(), Body := P.GetFortCharacter[]): Here := Body.GetTransform().Translation if (Here.Z < KillFloorZ, Who := Body.GetAgent[]): RespawnPad.Teleport(Who) Print("Caught a faller — sent home")