What to do for using multiple lights within class Blueprint?

Hey Folks,

i have a question for my following task:

I have different Rooms with a different count of spotlights “hanging” in each of the rooms. I have a lightswitch Mesh placed in each room to turn the specific spotlights on.

What i can do right now (i am new to this): I want to use the switch to turn the lights on in each room. So i could place each rooms spotlights and a switch+trigger in a class blueprint and handle my event in there. So i would create a calss bluprint for each room.

This “solution” seems bogous to me since i dont have a very good control of the positioning of the lights and switch.

Putting everything in the level blueprint seems very bad too.

So how can i create a lightswitch class to communicate with various lights which can still be positioned in the viewport?

Any ideas?

Create two blueprint actors named “BP_Switch” and “BP_Light”. Create a custom event named “ToggleLight” in “BP_Light” blueprint to turn the light on and off.

Create a variable of type “actor” named “lights” in the “BP_Switch”, click to the square-grid next to the variable to turn it into an array of actors. After compiling, you’ll be able to add “BP_Light” objects to this array. Then use a “foreachloop” as shown in the attached image to call for the ToggleLight custom event in each light listed in the array.

You can obviously change it to be triggered by sth else than Enter pressed.

Sounds good to me! Unfortunatley i cant get it to work. I have both packed into blueprints but the array variable wont find any to select. Here is a pic…

Ok, that worked. But i cant get them to communicate? I dont know how to add the “cast to xxx blueprint node”.

(and yes, i am bloody noob!) :smiley:

Thank you for your patience!

You can set it in the editor window (not the blueprint window) after selecting the variable in the scene. It should be listed in the details tab in the lower right corner. There should be an arrow next to it to expand/collapse the list. You can add elements to the array by clicking on the white plus icon.

So now this works. But i cant get it to wort because i am missing the “cast to” node. Dont know how to set this up.

And yes, i am bloody noob, but thank you for your patience.