Time goes wrong in the Build

Hello again, @Hellium I have a little question for you, please try to help :slight_smile:

So I have the effect which decreases its strength by time, everything is just okay in the (UnityEngine), but not in the build, in the build its strength goes very fast to zero, so I can’t even see it in the start of the scene, what can make the problem here?

void Update ()
	{
		oldTV.Strength = Mathf.SmoothStep (1, 0, Time.time / 5);
	}

Because Time.time is the time in seconds since the start of the game (time starts once all Awake functions have finished), supposing the Start functions take a lot of time to run, you may have this problem.

Try this:

float startTime ;

void Start()
{
     startTime = Time.time ;
}

void Update ()
{
    oldTV.Strength = Mathf.SmoothStep (1, 0, (Time.time - startTime ) / 5);
}

Or this:

bool strengthDecreasing ;
float startTime ;

void Update ()
{
    if( !strengthDecreasing )
    {
        strengthDecreasing = true ;
        startTime = Time.time ;
    }
    else
        oldTV.Strength = Mathf.SmoothStep (1, 0, (Time.time - startTime ) / 5);
}

Or even better:

float progress;

void Update ()
{
    oldTV.Strength = Mathf.SmoothStep (1, 0, progress / 5);
    progress += Time.deltaTime ;
}