using UnityEngine;

public class LetterPing : MonoBehaviour {
    public SpriteRenderer spriteRenderer;
    private Color startColor;
    private float timestamp;
    private float pingTime = 2f;
    private float targetAlpha = 0f;

    // Use this for initialization
    void Start() {
        spriteRenderer = GetComponent<SpriteRenderer>();
        startColor = spriteRenderer.color;
    }

    // Update is called once per frame
    void Update() {
        spriteRenderer.color = Color.Lerp(startColor, new Color(1, 1, 1, targetAlpha), (Time.time - timestamp) / pingTime);
    }

    // When radar collides with letter
    public void OnTriggerEnter2D(Collider2D c) {
        timestamp = Time.time;
    }
}