How to force an actor array to recognize a class

So, I have a complex question that I’m not sure how to describe. I have a box collision on one “enemy” that is supposed to detect neighboring enemies, which is fine and dandy. But later, said enemies need to perform an input. My “ComponentOverlapActors” node outputs an array of actors, but I need to find a way to either make the node output an array of the enemies’ class, or convert the actors array into an enemies array, so that I can tell all actors(enemies) within the array to perform the input.
342997-
342996-code-screencshot-1.png

Okay, I found a work-around, but this seems clunky, is there an easier less code consuming way to do this?

342998-code-screenshot-2.png

Ya, but the problem is that I physically can’t connect a general actor array pin (or a non-array actor pin) to a enemy array input, the blueprint just rejects it (unless there is an override for this?). Part of the problem is that I don’t know how to tell the engine that the only results that should be getting returned are enemy actors, so it should make a enemy array, instead of an actor array (which is non specific, and then the engine thinks that the actor pin and enemy input are non-compatible, since an actor could be ANY actor).

Or do you mean making a “cast to enemy” node, using the actor pin, and then if cast fails, then blah, and if it works, then just use the “As enemy” output to perform the “Swift Kill” Input? This seems like it would work well!

YEEEEESSS It does work, much less clunky than before! Thank You!

If I understood correctly, I think what you need to do is do a for each loop on your Actors array, and then drag from the array element pin and cast to Enemy Jump. If that cast succeeds, it means that the current array element is an Enemy Jump actor, and, you can then call your Swift Kill function on it.

Yes, that’s what I meant :slight_smile: Casting is basically checking to see if the passed object is of the cast type. It’s a very important and useful concept, I suggest that you read up on it, it will help you greatly in any project!

By using a for-each-loop that was connected to the actor array, I used a “cast to enemy” node, since the inputs allow pretty much any objects. With the cast node, I’m able to use the “As enemy” output pin to successfully run the custom input, and the code works flawlessly! Thank you Zeaf for your advice & help! :smiley:

342999-code-screenshot-3.png

Thank you, I will! :slight_smile: And thanks once again for helping me!