using UnityEngine;

public class Destructible : MonoBehaviour
{
    [SerializeField] private Animator animator;
    [SerializeField] private float destroyTime = 1f;

    private Rigidbody2D rb;
    private BoxCollider2D boxCollider;

    private void Start()
    {
        rb = this.gameObject.GetComponent<Rigidbody2D>();
        boxCollider = this.gameObject.GetComponent<BoxCollider2D>();
    }

    public void TriggerAnimation() {
        animator.SetTrigger("Destruct");
        rb.gravityScale = 0f;
        boxCollider.enabled = false;
        Destroy(this.gameObject, destroyTime);
    }
}
