Day and Night city lamps toggle visibility

I want to make the light lamps to turn off when is day time and turn on when is night.
This is my bp for day and night scene, but I do not think that will help me.

Watch tutorial about blueprint communication. Then look into time functions.
In this “SimpleSky” turn those tiny eyes on for hours and minutes.

Now create new blueprint name it for eg: BP_Light
Add light there as component.

On event tick do as follow:

  • get all actors of class and class is “SimpleSky”
  • From it cast to “SimpleSky”. This step is probably unnecessary. You can remove that node later, if you get warning about it.
  • from cast to do: “get Ore” “get O_zi” and whatever you need for lights to know
  • now your light blueprint should know time of day that is taken from “simpleSky” blueprint
  • change light radius strength or color depending on that time. Drag light component reference from component list, and write “Set” it should let you set its values.

PS. Watch tutorials really.

I did something like this in a project a while back. I used an enumeration to toggle the streetlights on and off in the streetlight bp. I set 24 elements in the enum (one for each hour). Then set a timer for a 24-hour clock (I believe I set that off the begin play in the event graph, but would have to track down the project to be sure). From the hours of 6pm to 6am, the lights were toggled on, and off from 6am to 6pm. There are probably better ways to go about this, but this way worked for me.

Set up an event in your day night cycle that sends out the current hour or something. On your lamp’s construction script or something make it find your day night cycle and have it listen for that event. On begin play and when it hears that event, it checks to see if it’s day or not. If it’s day, turn off the light, if it’s night, turn it on.

That way you can set up other things to work with the day night cycle too without having to modify your day night cycle every time, like having a church bell ring every hour x number of times, where x is the current hour.

Edit: I think you have to set it up to begin listening for that event on Begin Play, but still, the idea is the same.

Also, this way, the only thing that happens in the tick function is incrementing the time, the only time we check to see if the light should be on or off is on BeginPlay and when the hour increments