Skip to content

Instantly share code, notes, and snippets.

@MattRix
Created March 29, 2023 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattRix/f7647d341eac10b32389f6535c039c71 to your computer and use it in GitHub Desktop.
Save MattRix/f7647d341eac10b32389f6535c039c71 to your computer and use it in GitHub Desktop.
A Verse script that detects when the player starts and stops moving
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
movechecker_device := class(creative_device):
var IsPlayerMoving : logic = false
OnBegin<override>()<suspends>:void =
for(Player : GetPlayspace().GetPlayers()):
OnPlayerAdded(Player)
GetPlayspace().PlayerAddedEvent().Subscribe(OnPlayerAdded)
OnPlayerAdded<private>(Player : player):void =
spawn { CheckForMovement(Player) }
CheckForMovement<private>(Player : player)<suspends>:void =
if(FortChar := Player.GetFortCharacter[]):
var OldPos : vector3 = FortChar.GetTransform().Translation
loop:
NewPos := FortChar.GetTransform().Translation
Dist := Distance(NewPos,OldPos)
set OldPos = NewPos
if(Dist > 0.0):
if(not IsPlayerMoving?):
set IsPlayerMoving = true
HandlePlayerStartedMoving(Player)
else:
if(IsPlayerMoving?):
set IsPlayerMoving = false
HandlePlayerStoppedMoving(Player)
Sleep(0.1)
if(not GetPlayspace().GetPlayers().Find[Player]) then break #player was removed
HandlePlayerStartedMoving(Player : player) : void =
Print("Player Started Moving!")
HandlePlayerStoppedMoving(Player : player) : void =
Print("Player Stopped Moving!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment