#Hastebin

1 messages · Page 1 of 1 (latest)

hollow cobalt
#

Your timer logic is faulty:

foreach (char letter in text[iterations].ToCharArray())
{
    newTxt += letter;
    float time = 0;
    while (time < TextSpeed)
    {
        time += Time.deltaTime;
        yield return null;
    }```
#

The problem here is that you are starting a new timer for every letter

#

let's say the time between letters is 1 second

#

this code is goingt o wait until time >= 1

#

In reality that number is going to be something like 1.05 or 1.01

#

since you then start a brand new timer for the next letter, that .01 or .05 seconds is lost

#

And the slower the framerate, the larger those errors are going to be

#

In effect your code is just as bad as yield return new WaitForSeconds(...)

#

What you need to do is reuse the same timer variable

#

so when you do:

 while (time < TextSpeed)
 {
    time += Time.deltaTime;
    yield return null;
 }

 time -= TextSpeed;
 // now time still has that extra `0.05` seconds in it. So next time you'll correctly only wait 0.95 seconds instead of a fresh new 1 second