Created
March 29, 2023 19:11
-
-
Save MattRix/f7647d341eac10b32389f6535c039c71 to your computer and use it in GitHub Desktop.
A Verse script that detects when the player starts and stops moving
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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