Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MiklosMatyas/94d11ea0d791aeae78baf72653ec480f to your computer and use it in GitHub Desktop.
Save MiklosMatyas/94d11ea0d791aeae78baf72653ec480f to your computer and use it in GitHub Desktop.
Get closest player to prop in UEFN and Verse
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
GetClosestPlayerToProp(AllPlayers: []fort_character, Prop : creative_prop): ?fort_character =
var ClosestPlayer : ?fort_character = false
var ClosestDistance: float = 1000000000.0 # initialize with a large number
for (Player : AllPlayers):
EDistance := Distance(Prop.GetTransform().Translation, Player.GetTransform().Translation)
if (EDistance < ClosestDistance):
set ClosestPlayer = option{Player}
set ClosestDistance = EDistance
return ClosestPlayer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment