using UnityEngine;

public class ObjectDeleter : MonoBehaviour
{
    [SerializeField] GameObject objectToDelete;

    AudioSource use;

    [SerializeField] SpriteRenderer spriteRenderer;
    [SerializeField] Collider2D thisCollider;

    private void Start()
    {
        use = GetComponent<AudioSource>();
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.GetComponent<Player>() != null)
        {
            use.pitch = Random.Range(0.95f, 1.05f);
            use.Play();

            objectToDelete.SetActive(false);
            thisCollider.enabled = false;
            spriteRenderer.enabled = false;

        }
    }

    public void Reset()
    {
        objectToDelete.SetActive(true);
        spriteRenderer.enabled = true;
        thisCollider.enabled = true;
    }
}
