using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/Diagnostics }
# WHO'S PLAYING? — find the player's character and read its state.
#
# There is no "give me the player" global. You walk a short chain:
# this device -> its playspace -> the players in it -> each player's
# fort_character (the body that runs around the map). Once you hold a
# fort_character you can ask it where it is, where it's looking, and what
# it's doing right now. This device prints a quick status report for every
# player when a Button is pressed — a roll-call you can drop into any island.
char_roll_call_device := class(creative_device):
# Press this to run the roll-call.
@editable
ReportButton : button_device = button_device{}
OnBegin<override>()<suspends> : void =
ReportButton.InteractedWithEvent.Subscribe(OnReport)
# Fires each time a player presses the button.
OnReport(Presser : agent) : void =
# Step 1: every device lives inside a playspace. Ask for ours.
Playspace := GetPlayspace()
# Step 2: the playspace knows every human player currently in the match.
AllPlayers := Playspace.GetPlayers()
Print("Roll call: {AllPlayers.Length} player(s) in the playspace")
Verse Library
verse
03 Device
Subscribes to a button press to retrieve and iterate through all current players in the playspace.
verse-library/verse-char-find-player/03-device.verse
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.