Casting an event to an array of actors ?

Hi people

So I have a switch BP in my game that has to affect many different BP classes. Right now I made it work with a big ■■■ event dispatcher in my FirstPersonCharacter BP, that receives a custom event from the Switch and casts to all the different BP classes that I want.

http://img15.hostingpics.net/pics/324784Capture.png

but this is not good enough as I need to cast it to even more classes and I want to have one event casting to all of them or I will have to make zillions of events for one thing. Also the event that I’m casting to them has the same name in every one of those classes. So in my switch BP, in the construction script, I tried to add all the classes I wanted to affect in a single array, like so :

But then, in my FirstPersonCharacter, I can’t find a way to cast that same event to all the classes in my array. Here’s what I have so far :

http://img15.hostingpics.net/pics/789988capt3.png

I copied that custom event node but it can only target ONE BP class with it, how can I cast the event to all my array since they all have that custom event in them ? Am I doing it all wrong and maybe there’s a more appropriate way to do this ?

Sorry for the noob question but I cant seem to figure out if the type of communication Im using is the right one, and if Im using it wrong.

Thanks for your time

I’d recommend to make use of inheritance here. Basically, all your cube classes have one shared ancestor class (most likely Actor). All functions defined in that ancestor class are known and can be used in all its child classes. Now the Actor class is too generic for your purposes (because a lot of Unreal-internal classes are actors, too) but you can define your own shared ancestor class that handles all the shared behavior of your cube actors.

To do this, create a new Actor class and reparent all your cube classes that currently have Actor as their parent to the new class. As a result, they’ll all be children of this new class. You can define an event or function in the base class and have each child class decide independently what’s supposed to happen when that event or function is called.

This has two enormous benefits: First, you can greatly simplify collecting all objects of a certain class by passing the shared base class into GetAllActorsOfClass instead. Second, rather than try to compare each array element’s class type, define one function in the base class (e.g. HandleSwitch) and override it in each child class to handle its specific behavior. So for one class HandleSwitch would call COLOR SWITCH, for another COLLISION SWITCH.

It’s a bit unclear what you’re trying to do so I can’t give a specific example. Just ask if you have any questions.

I hope this helps. Good luck!

thanks a lot ! I will try that