How to turn the emission on and off in a material based on a day/night cycle?

I have implemented a day/night system that turns the lanterns on and off after a certain amount of time. Now I want to create a material for windows and co, which has the color blue as the basic color during the day and does not glow, and from a certain time in the game a yellow glow should be activated in the material, which will later be deactivated again at a certain time.

My day/night system runs via the level blueprient, but as far as I know you can’t add any materials to it, which would allow me to control the emission through a timeline or something similar.

Do you have any ideas or suggestions regarding this?

There are two ways to do this.

The hard way:

You can iterate through all actors having some particular tag, and then iterate over the materials in those actors. You’ll probably want to do this on start-up, and create Material Instance Dynamic for the materials, and remember all the instances in your level blueprint. Then when time comes to change the material parameter, iterate over all the saved materials.

You’ll want to use a material parameter that’s a float, and multiply your emissive color by this float before it goes into the material parameters output.

The reason this “hard way” might be useful, is if you want to slowly turn on different objects at slightly different times, which requires a separate material instance per object.

The easy way:

1 Like

Thank you very much. The “easy way” does its job perfectly.