How to get all ennemy position ?

Hello everyone,

I have a little problem of optimisation here.

I’m making a shoot 'em up
In a level I have enemy spawning every now and then
I want the player to teleport to enemy position when I press a key

Actually I’m using “Get all actor with tag”, however it’s written in the BP comment, that is a slow operation (and it is…) and that I can’t use it everyframe.
–>So I’m using this BP only when a new enemy is concerned by the teleport (so I will not cast multiple get all actor with tag for nothing).

However, it’s still very slow and demand many ressources…

Maybe someone know another solution, less demanding on ressources, in order to get all “enemy” actor in a level please ?

Thanks a lot !

Please find the BP here —> sorry for the mess, still WIP

what’s the max number of enemies in the level at any given time? And what’s the rate of spawning new ones?

Thanks @Rev0verDrive for your answer.

Max enemies can go to 30, and they appear every 1 seconde.

One way to handle this is when the server spawns one it adds it to an array. Say in the Game Mode. You’d then just get an updated reference to the array. When one is destroyed, have it removed from the array (Game mode).

Oh Thanks a lot !
I’ll give it a try tomorrow and I will compare with the method I actually use. :slight_smile: