Created
May 10, 2023 15:01
-
-
Save WahlbeckUEFN/2c36aba9b50823466d1eb350672fa7ce to your computer and use it in GitHub Desktop.
Get closest player to prop in UEFN and Verse
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 { /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 |
nice, this can be used for finding targets in tower defense game for the turrets 🚀 . thanks for sharing!
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
hello
can you help me ?
i need to spawn a bot with random battle royal skin in the current player location when i press a custom key in my keyboard