Light intensity Lerp not functioning properly

I’m working on a Day/Night cycle, while I’ve got the clock time sorted, I want the Directional Light to transition its intensity from 1 to 0.3 over the course of time a bool is active. And then vice versa 12 “hours” later.

alt text

When I try this the intensity of the light hovers around 0.99 (More like 0.998564) and will not go lower, the intensity seems to bounce around like the value is being constantly reset, but I can’t see why.

Again, so long as the beginTransition bool is active, the light should either go from [0.3 to 1] or [1 to 0.3]

I think you’re misunderstanding the 3rd argument of the Mathf.Lerp() function. With a stable fps, Time.deltaTime is pretty much a fixed number and from the code snippet you’ve given, so is duration. This means that in every frame you’re passing to the function the same value. In the docs it says:

Linearly interpolates between a and b by t.

The parameter t is clamped to the range [0, 1].

When t = 0 returns a.
When t = 1 return b.

When t = 0.5 returns the midpoint of a and b.

So if t stays the same number (not a increasing/decreasing value), Lerp() will keep returning the same value. There’s sample code on how you should use the function properly in the link given.