using UnityEngine;

public class DeleteSelf : MonoBehaviour
{

    [SerializeField] float timeToDelete;

    private float currentTime;

    [SerializeField] SpriteRenderer sprite;

    // Update is called once per frame
    void Update()
    {
        currentTime += Time.deltaTime;
        if (currentTime >= timeToDelete)
        {
            Destroy(gameObject);
        }
        if (sprite != null)
        {
            float percentage = currentTime / timeToDelete;
            sprite.color = new Color(1,1,1, percentage);
        }
    }
}
