Keeping track of actors in level?

Hello all, I have question regarding actors mainly enemy ai classes. In game I have 14 enemy spawner blueprints spread out through world which every 20 seconds it decides if it spawn classes in array which are 2 different enemy types. By default it spawns both enemies at same time at each spawn point. I rigged up a not so great enemy counter that just randomly subtracts 1 from the enemy counter if its 2x over the character level. So in all reality im not keeping track of enemies in world im just setting numbers to recreate this feature. Question is how do I keep track of actors in world before and after I destroy them?

Here is the enemy spawner which you see it calls the class array in a foreachloop then spawns enemies. How to I correctly track the enemies in world?


This one below is in the Enemy blueprint which checks the health and destroys actor when health is 0.


Now I have tried several different ways in doing this all failed attempts, if someone can please point in right direction on how to do this i’ll be forever greatful… Thank you!

a couple functions help out with this, but just be careful of use because they are iterators. in your game state or something, create a function called ‘getEnemyCount’ or whatever, and call a ‘GetAllActorsOfClass’ with the class specified to whatever the parent class is of all your enemies (or if you have one enemy class, that class would work. this returns an array. get the length of the array, and that’s your count. then you can call this function anytime you need the enemy count, but don’t put it in tick. In terms of understanding when an enemy is killed…this is another scenario. create a function in your game instance or wherever that can oversee the kills and keep track of who killed who. so for example, when an enemy takes damage, notice that damage can pass the type, instigator, and actor that caused the damage. the enemy then needs to pass this information, including a reference to itself, all over to the game instance or mode, so that a record can be kept of this data for future reference.

Oh man thank you so much, something as simple as calling vector length lol now im all set. Thanks again very much appreciated!