I’m trying to monitor the state of a current lerp, and then start another lerp mid lerp of the first lerp!
(sorry just like typing lerp!)
But seriously, If I have a Mathf.Lerp making a number go from 1-0, I’m trying to start another lerp when that number reaches say the mid point (.5). But for some reason, I’m not getting the results I’m after.
Here’s my code;
if ( lives == 0 )
{
var t: float = 0.0f;
var on: float = 1.0f;
var off: float = 0.0f;
while(t < 1)
{
t += Time.deltaTime / panelFadeOutTime;
panel.GetComponent(UIPanel).alpha = Mathf.Lerp (on, off, t);
yield;
}
}
if (panel.GetComponent(UIPanel).alpha <= .8)
{
var r: float = 0.0f;
while(r < 1)
{
r += Time.deltaTime / panelFadeOutTime;
panelLose.GetComponent(UIPanel).alpha = Mathf.Lerp (off, on, r);
yield;
}
}
These lerps are controlling an alpha attribute of two different sprites, I’m simply trying to fade one down and fade one up just before the first one fades down.
What’s happening with this current code is one will fade down completely, and then one fades up.
thanks for reading!