Day and night cycle Lag issue

My game was running at 50 fps. Then i added a directional light which rotated 0.1 every update frame. It dropped down to 30 fps :frowning: the script has only one line of code…

void Update ()

transform.Rotate (0,0.1,0); 


Why is it lagging now? Plz help. I have a terrain and i know terrains lag but the light spinning made it drop 20 frames per second. Why?

Shadow calculations take a lot of processing power. Try opening the Profiler window (Window → Profiler) and looking at what’s causing the issues. You can lower shadow quality (settings and descriptions found here), and if the problem remains severe or the lowered shadow quality is too much of a performance hit, try Enroq’s suggestion of lowering the rate at which the rotation occurs to cut down on recalculations.

Basically because lighting is a very expensive process, which is why if you can you should be baking. Every time you rotate that light it has to calculate new shadows and light gradients for every object in the game with a renderer.

Consider abandoning the update function and running a parallel routine that updates this once every second.

Instead try increasing and decreasing the intensity of the light to simulate day night instead of rotating or moving it.