using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TakeDamage : MonoBehaviour
{
    public GameObject explosionParticle;
    public AudioClip explosionAudio;
    public float health = 1f;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {

    }

    public void Damage(float damage = 1.0f){
        health -= damage;
        if(health < 0.01f){
            AudioSource.PlayClipAtPoint(explosionAudio, transform.position);
            GameObject clone = Instantiate(explosionParticle, transform.position, Quaternion.identity);
            Destroy(clone, 3.0f);
            Destroy(gameObject);
        }
    }
}
