implement floating text

What would be a proper way to achieve this? There are guides around but they do not work on multiplayer.

I have set up this “floating damage text”, and it works. However I am worried because everytime a player does a damage, my code will iterate (GetActorsOfClass …) through all “players” (not actors, only active players) and if the player is near the damaged actor, it will create a widget on the controller showing the floating text above the Actor that was damaged. However I believe this would be quite cpu intensive or something, since if the game has 300 users on the map, it will execute that function, itterating over all those players all the time…

Is there a proper way to get nearby actors from another actor, without the need of iterating through all active players?
Or maybe a better way to achieve this?
Regards!

https://s29.postimg.org/q0boykhbn/blop.png

Probably a rectangle (i think sphere doesn’t exist in UE) raycast (trace) or an overlapping collision.
Dunno if it would be better, or even faster than iterating through 300 players.

Or just split up the iteration (split up the player count) and make 10% per tick. Doesn’t matter (in this case) if some players get it (1-10 ticks) later than others.

e/ And you don’t have to use “get all actors by class” - you could use an iteration through player controllers too - probably.
I don’t know the science behind get all actors by class, but iterating through controllers should be faster, i think.

Iterating player controllers or player pawns is not any different performance-wise. And there is most definitely a sphere trace. I’d this a networked game? Just spawn the text and use network relevancy to handle whether to spawn it or not