How to make actor detect closest player, and save it in variable?

How to make actor detect closest player, and save it in variable? (function), please help.

  1. Find all actors of class
  2. For loop these and do:
  • calculate distance (I believe this is a node) between the two actors
  • Check if this distance is closer than the saved distance
  • Save this distance AND the actor if closer

You’ll need:

  1. A distance (float) variable
  2. Prob an actor variable or whatever type you’re distancing to

Hello Zedory,

This was asked recently and there was a really nice blueprint graph that was given in a response. It’s basically what Evie Games described, where you overwrite the reference ONLY if the distance is closer.

(Image credit goes to BRGCooper)

1 Like

hi
is this resolved ?