Get all actors of class not getting all actors in level

So right now I have run into a problem in my paper2d project. It seems as if the get all actors of class are not getting all actors of class. I have two instances of an AI character in my game and right now I have it set up to where if on overlap is enemy then damage the enemy. Well it will only damage one of the enemies and none of the others. Below is how I am calling all actors of class.

Instead of just using a ‘Get’ element at index 0, from the array output of ‘Get All Actors of class’, try connecting the output to a For Each loop and then for each element in the array, apply damage.

Ok so I tried doing this and it still isnt registering for other instances in the level of the enemy. What am I doing wrong lol.

After the for loop, you’re storing all instances onto the same ‘EnemyRef’ variable. So what ever was stored in it before that gets erased. Instead try adding them to an array. Then once the for loop is completed, you can check out the array length to see if all enemy units are accounted for. Same for your Smart Enemy Blueprints as well with a separate array and for loop.

You mean kind of like this?

Instead of using make array in the for loop execution, get use ‘Enemy ref array’ and use the ‘Add’ function for arrays. This way as the for loop executes, you can add each Array Element from the loop into your Enemy array one by one.

I am still getting confused by this because how would I reference an actor from the array for an oneventoverlap if actor == this object then kill type of thing.

You could get your player character, cast it to your PlayerBP, and then get the Enemy ref array that you’ve stored above. This can be done from any other blueprint. Once you have the array, just check if the particular enemy actor is in the said array by using the ‘Contains Item’ node for the array. You can check out all the array functions in the documentation: Array Nodes. It would probably ease out the learning process if you know the built in array nodes that you can use to your advantage.

Sweet! I got that part to work now I am trying to have it so when the actor that is being referenced is destroyed delete it from the array.