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
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.
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.
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!