I have figured out how to control visibility of a ceiling light with a switch on a wall through blueprint communication, but I would like to duplicate the switch and have the new copy control a different light. Is there a way to choose which light a switch can control after adding to the level? I need to be able to list all the lights in the level and be able to select the one I want for a particular switch.
When creating your switches, you can create variables that are references of other blueprint classes. If you create a new variable and search for the name of your light blueprint class you’ll find it.
Once you’ve created this reference variable, you can make it an array so it can hold as many references as you need. All you have to do after that is make it editable. This way you can add lights from the level as elements to the variable.
After that you can set your switch up to loop through each element in the array (in this case all of the lights on the list) and for each one of them you can call the function that turns it on or off.
I hope that helps, let me know if you have issues.
Hey, An easier option I found was to add a integer array variable within the Light Actor BP and have it set to 0 as default.
Now from the light switch I have Light Zone variable as the integer array. I do a get all actors of class and then For Each Loop, if the Light Actor integer value matches the switches? Switch! I also leave 0 as a master to switch all and then add to the array another number for zones. So id have say room 1 as 1 and room 2 as 2 and if I wanted a master switch? Leave 0 in the array to switch both areas at once. (Makes for cool power cut simulation :P)
Simply add or remove integer values to the array to get desired switching!
Thanks very much for your answers. I realized part of my problem was I was making blueprints out of the light fixtures with the pointlight embedded. What I really needed was a blueprint of just the pointlight. Now, as you mentioned, I can select the preferred light from the reference list and parent it to the light fixture!
This was my issue as well. I had created a light with a fixture around it and spent over an hour trying to figure out why the BP wasn’t working to change the visibility and start a gradual color changing script. Felt like such an idiot, it was so obvious once I read your post that I was referencing the object and not the light. There’s definitely a way to reference the light itself, but at this point I have no idea how to do so and your post gave me exactly what i was looking for. Thanks for coming back to say something, or I would’ve spent I don’t know how long on such a simple solution.
That’s awesome! Thanks for the feedback