// Update is called once per frame void Update() { float u = ((Time.time - (birthTime + lifeTime)) / fadeTime); if (u >= 1) { Destroy(this.gameObject); return; } if (u >= 0) { flashTime += Time.deltaTime; float z = Mathf.Abs(Mathf.Sin(flashTime * flashSpeed)); color.a = Mathf.Lerp(0, 1, z); spriteRend.color = color; } if (boundaryCheck.Offscreen()) { Destroy(gameObject); } }