// Update is called once per frame void Update() { if (moods == null) { moods = this; } heartbeat = (moods.GetComponent <Image>().color != neutral); if (heartbeat) { Color init = GetComponent <Image>().color; float pulseUpper = pulseMax; init.a = Mathf.Lerp(pulseMin, pulseUpper, t); GetComponent <Image>().color = init; if (!waning) { t += pulseTime * Time.deltaTime; if (t > 1.0f) { waning = true; } } else { t -= pulseTime * Time.deltaTime; if (t < 0f) { waning = false; } } // if (t < 0) // MoodSwitch(moods.neutral); } }