using UnityEngine;

public class SmokePuff : MonoBehaviour 
{
    public float Lifetime = 1f;

    private SpriteRenderer rend;
    private float spawnTime;

	void Start () 
	{
        rend = GetComponent<SpriteRenderer>();
        spawnTime = Time.time;
    }
	
	void Update () 
	{
        float age = Time.time - spawnTime;
        if(age > Lifetime)
        {
            Destroy(gameObject);
            return;
        }

        float factor = age / Lifetime;

        rend.color = new Color(1, 1, 1, (1 - factor));
        transform.localScale = Vector3.one + 2 * factor * Vector3.one;		
	}
}
