Set Actor Closest To Player?
Hello I'd like to get the closest actor from my player and set it as a variable, I used get all actors of class along with a for each loop and compared the distance from the actor to my character using the get distance to node but it only seems to set only one of the actors and doesn't update to the next closest actor.
I assume I'm using for each loop wrong or something. Any help would be appreciated thanks!
asked May 16 '19 at 10:48 PM in Blueprint Scripting
Thanks for clarification, this should do the trick:
To make it more efficient you could have an overlapping sphere that checks only for actors in proximity. Checking against actors that are far, far away may not be necessary - although this would depend on how your game is structured, of course, and may make perfect sense.
If you have a fixed amount of actors to check against, it would also make sense to gather them in an array only once and then perform periodic checks on the results.
Follow this question
Once you sign in you will be able to subscribe for any updates here