Hi guys, my code is not working, surely a dumb mistake but i can’t found it. The scripts scale bigger a game object and then return to his sclae, using Vector3.lerp.
The first part works good : Fade in (I know it’s not a correct name for this function)
and for the FadeOut i’ve just invert the script but i think i’m missing something.
if anyone can tell me what’s the problem, here’s the code :
IEnumerator FadeIn(GameObject obj)
{
float progress = 0;
while (progress <= 1)
{
obj.transform.localScale = Vector3.Lerp(startPos, endPos, progress);
progress += Time.deltaTime;
yield return null;
}
StartCoroutine(FadeOut(obj));
}
IEnumerator FadeOut(GameObject obj)
{
float progress = 1;
while (progress >= 0)
{
obj.transform.localScale = Vector3.Lerp(obj.transform.localScale, startPos, progress);
progress -= Time.deltaTime;
yield return null;
}
}