using UnityEngine;

public class FlashPop : MonoBehaviour 
{
    public float LifeTime = 1f;
    public float Intensity = 1f;

    private float start;
    private Vector3 pos;
    
	void Start () 
	{
        pos = transform.position;
        start = Time.time;
        Destroy(gameObject, LifeTime * 1.5f);
	}
	
	void Update () 
	{
        float portion = (Time.time - start) / LifeTime;
        if (portion > 1)
            return;

        Vector3 warpedScale = new Vector3(0.6f + 0.4f * portion, portion, 1);
        transform.localScale = (Intensity) * warpedScale + (1 - Intensity) * Vector3.one;

        float bounce = Mathf.Cos(portion * 5 * Mathf.PI);
        transform.position = pos + Intensity * bounce * (1 - portion) * Vector3.up;

    }
}
