Trying to use an Event Dispatcher from the level blueprint to to toggle the lights of a class blueprint. I’m trying to make this change for ALL uses of that class blueprint so I don’t need to reference each individual one.
For example, I have a street light class blueprint that I’ve used throughout the level that I want toggled on/off during the night/day. I’d like to just use a single event to bring changes to all of these Street lights at once.
Use a “Get All Actors of Class” for the class blueprint, then use a “ForEachLoop” with the array of actors output on Get All Actors of Class plugged into the ForEachLoop. Within the loop you want to run a cast to node specifically looking for your streetlight blueprint. Finally, activate the function that turns on/off the lights from the cast to node. I am attaching an example image here. Effectively I set them on a timer of .05 seconds to toggle the streetlight on and off. You can change this to match your day/night cycle. In both instances I use custom events to be able to draw the specific information I needed to the level blueprint.
I have a smiliriar problem. Your solution works but is not ellegant. It would be much clearer if level blueprint could just call event dispatcher and notify all streetlights that they should turn off.
But I dont know how blueprint class (streetlight) can acces and bind to event dispatcher defined in level blueprint ?