Skip to content

Instantly share code, notes, and snippets.

@WahlbeckUEFN
Created May 10, 2023 15:01
Show Gist options
  • Save WahlbeckUEFN/2c36aba9b50823466d1eb350672fa7ce to your computer and use it in GitHub Desktop.
Save WahlbeckUEFN/2c36aba9b50823466d1eb350672fa7ce 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
@MiklosMatyas
Copy link

Hi,
Thank you for sharing. Can you help me how to use this function? I mean how to store this return value, and how to assign something to that Player?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment