Skip to content

Instantly share code, notes, and snippets.

@MattRix
Last active March 28, 2023 22:48
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/39e8c09ac5ad5727f4cd3a9ac2765486 to your computer and use it in GitHub Desktop.
Save MattRix/39e8c09ac5ad5727f4cd3a9ac2765486 to your computer and use it in GitHub Desktop.
Movement Detector Device in Verse for UEFN
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
movement_detector_device := class(creative_device):
@editable
MinimumMovementDistance : float = 100.0
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)
if(Dist > MinimumMovementDistance):
set OldPos = NewPos
HandlePlayerMoved(Player)
Sleep(0.1)
if(not GetPlayspace().GetPlayers().Find[Player]) then break #player was removed
HandlePlayerMoved(Player : player) : void =
Print("Player Moved!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment