Hi guys,
I have this code which is called via InvokeRepeating("NewHighscore", 0, Time.deltaTime);
public void NewHighscore()
{
if(hsDoOnce)
{
hsLerpTime = 0;
hsDoOnce = false;
}
if(hsGrow)
{
levelCounter.fontSize = Mathf.CeilToInt(Mathf.Lerp(100, 200, (hsLerpTime += Time.deltaTime)* 2));
if(levelCounter.fontSize >= 200)
{
hsLerpTime = 0;
hsGrow = false;
}
}
else
{
levelCounter.fontSize = Mathf.FloorToInt(Mathf.Lerp(200, 100, (hsLerpTime += Time.deltaTime)* 2));
if(levelCounter.fontSize <= 100)
{
hsPulseCounter--;
hsLerpTime = 0;
hsGrow = true;
if(hsPulseCounter <= 0)
{
hsPulseCounter = hsPulseOriginal;
hsDoOnce = true;
CancelInvoke ("NewHighscore");
}
}
}
}
I expect the score font, which is a UI Text, to pulsate with equal speed three times. Instead it may do one pulse fast then the rest two slow, or all three slow or all three fast, etc.
I don’t understand what causes this behaviour.
I thought it may be due to the rounding up of the int, but that’s not the case, I tried without the roundup and it’s the same.
Any ideas what may be wrong?
Thanks!