Get all actors of class/casting can only modify one array instance per cast? (lights and lightswitch)

I’ve got a light switch set up in my project with two blueprints: Lights_BP, and LightSwitch_BP.
Upon overlap event I enable input. If I then hit E it will turn on my light. If I hit E again, my light will turn off. It works great with a single light, but I would like to be able to turn on and off an array of lights I place in my room.
I’ve included a screenshot of my lightswitch_BP and Lights_BP

I’d like to be able to >Get all actors of class>all instances>cast to lights_BP>Set Targets
If this is not a reasonable idea or way of going about such things advice is appreciated :slight_smile:

lights in question:

Hi JoshieZombie

Placing a “ForEachLoop” after GetAllActorsOfClass should do the trick. Simply connect the the top Execution line and the Array-Element with the cast to Light_BP node. The Blueprint should then iterate over all elements in the Actor-Array, cast each element and switch on/off the light accordingly.

-Elewyth

Hello Elewyth!
I’ve done what you mentioned as shown below, but it seems to hang on the last element in the array. If I place three lights it only toggles the last light that was placed. Is this possibly due to me having connected this to the overlap event? I feel like it’s only looping once when I enter the overlap box.

http://i.imgur.com/LXBWD8k.png

Hi!

If you work with array, then you should use ForEach Loop node for change attributes in more than one object.

Thank you! This is what Elewyth suggested. Your comment helped me figure out my event mistakes though. I’ve got it running smoothly now :slight_smile:

Okay I’m back with another part to this question! I hope it is an easy thing to do!
I have trigger volumes set up in each room of my house. I was thinking I could use these to group which lights turn on and off. Do you know of a way I could go about doing this?
EDIT
Solved using enumerators!

Try to use Tag attribute

And to LightSwitch_BP add variable and condition.

All you need, is set tag for the lights and for the volume.