On and Off Lights doesn't seem to work properly now

Hey, everyone. I’m having trouble trying to make this work properly. I have actors in the scene that have lights in it and I use the GetActorsOfClass to round them up and used a For Each Loop to access the Rect Lights and set it’s visibility vise-versa using the Flip Flop. However, it works half as expected. Meaning I can get the actors on the scene, but only 3 actors have their lights turned off and the other half stays on and whenever I click the button again, the first 3 actors now turn on and the second 3 actors now turn off (vice-versa). I’m unsure what I did wrong here.

Here’s a look at my Blueprint

Any help will do. Thanks in advance!

Print the length of that array and compare it to the number of actors in the scene. Perhaps they’re of another class.

What is the initial state of the lights? Are they all off?

Thank you for your reply. :slight_smile:

LightActors

The number of actors in the scene and the length of the array are equal and it seems that when I add the Flip Flop node, the issue occurs. But when I remove that node and directly connect to the set visibility false, all lights turn off.

It makes sense. Flip Flop remembers its state during the loop. So when you flip the 1st light on, the 2nd one will be turned off. The 3rd one will be on, and so on… (and off)


You probably want something along the lines of:

Use the actors the For Each spits out, ofc - this is just an example.

1 Like

Thanks for the reply! Got it to work now about what you said about the Flip Flop node. It’s similar to what you did. Thank you again very much!

1 Like