using UnityEngine;

public class WeaponHitSpriteSwap : MonoBehaviour 
{
    public Sprite HitSprite;
    public float SwapTime = 0.5f;

    private Sprite normalSprite;
    private SpriteRenderer rend;
    private float switchBackAt;

	void Start () 
	{
        rend = GetComponent<SpriteRenderer>();
        normalSprite = rend.sprite;

    }
	
	void LandedHit() 
	{
        if (HitSprite == null)
            return;

        rend.sprite = HitSprite;
        switchBackAt = Time.time + SwapTime;
	}

    void Update()
    {
        if (rend.sprite == HitSprite && Time.time > switchBackAt)
            rend.sprite = normalSprite;
    }
}
