I have a value counting up from 12 to 200 using a lerp like this:
globalSpeed = Mathf.Lerp(12, 120, Time.time * 0.0015f);
When restarting the game with:
The globalSpeed variable continues to count from where it stopped last time, how can I fix this?
The easiest way is to have a float variable that is made 0 in Start.
In Update just make
yourVariable += Time.deltatime;
Use yourVariable instead of Time.time in your lerp.
Another solution will be to use a float variable to cache the Time.time in Start and then your lerp will became
globalSpeed = Mathf.Lerp(12, 120, (Time.time - yourVariable) * 0.0015f);
How about using Time.timeSinceLevelLoad instead of Time.time. That should solve the problem.