Polling Player Speed in Verse
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Simulation }
# Message type to get player name for printing / debugging
PlayerNameMessage<localizes>(InPlayer:agent):message = "{InPlayer}"
# A Verse-authored creative device that can be placed in a level
speedometer := class(creative_device):
# Time to elapse between updates to player speed (in seconds)
@editable
TimeBetweenSpeedChecks:float = 1.0
# Button device to signal cancelling the player speed loop.
@editable
Button:button_device = button_device{}
# Custom event to cancel the loop. Same event for all players.
# Can change to different events for each player, if needed.
EndPolling:event() = event(){}
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
Button.InteractedWithEvent.Subscribe(OnButtonInteractedWith)
# Get all players in session and spawn their async speed loop
for (Player : GetPlayspace().GetPlayers()):
spawn{ PlayerSpeedLoop(Player) }
# Event handler for button device
OnButtonInteractedWith(InAgent:agent):void=
EndPolling.Signal()
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.