using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } using { /Verse.org/SpatialMath } using { /UnrealEngine.com/Temporary/Diagnostics } # MOVE THAT CHARACTER — push the player's body around from Verse. # # Once you hold a player's fort_character you can move it two clean ways: # * SetLinearVelocity — DIRECT. Set how fast and which way they're moving # right now (meters/second). The launch-pad punch. # * ApplyLinearImpulse — PHYSICS. A one-off shove in Newton-seconds, blended # with whatever they were already doing — a softer nudge. # (A third, TeleportTo, blinks them instantly to a spot — we use it in the # capstone, where it pairs with the kill-floor catcher.) # # This device wires a Button to a "launch" that flings every player straight # up — a crowd-pleaser bounce pad you can drop into any island. # # AXIS NAMING: a /Verse.org/SpatialMath vector3 uses Forward / Left / Up # (the same Scene Graph convention you met in the Animation series) — NOT # X / Y / Z. Up is the vertical axis, so an upward pop sets only `Up`. char_launcher_device := class(creative_device): # Press this to launch everyone. @editable LaunchButton : button_device = button_device{} # Upward launch speed in meters/second. Designer-tunable. @editable LaunchSpeed : float = 15.0 OnBegin() : void = LaunchButton.InteractedWithEvent.Subscribe(OnLaunch) OnLaunch(Presser : agent) : void = Playspace := GetPlayspace() # Loop bodies of every player who currently HAS a character. The # `Body := P.GetFortCharacter[]` in the for-clause both fetches and # filters: players mid-respawn (no body) are simply skipped. for (P : Playspace.GetPlayers(), Body := P.GetFortCharacter[]): # Set an upward velocity. Forward/Left stay 0 so it's a clean pop. Up := vector3{ Forward := 0.0, Left := 0.0, Up := LaunchSpeed } Body.SetLinearVelocity(Up) Print("Launched a player upward at {LaunchSpeed} m/s") # A gentler alternative: a physics shove instead of a hard velocity set. # ApplyLinearImpulse adds to current motion rather than replacing it, so a # running player keeps their forward momentum and just gets bumped upward. Nudge(Body : fort_character, Strength : float) : void = Push := vector3{ Forward := 0.0, Left := 0.0, Up := Strength } Body.ApplyLinearImpulse(Push)