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

public class BulletScript : MonoBehaviour
{
    int damage;
    float life = 5;
    // Use this for initialization
    void Start()
    {
        GetComponent<Collider2D>().isTrigger = true;
    }
    private void Update()
    {
        life -= Time.deltaTime;
        if (life <= 0)
        {
            Destroy(this.gameObject);
        }

    }
    // Update is called once per frame
    public void SetDamage(int _D)
    {
        damage = _D;
    }
    private void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag!= this.tag  /*&& GetComponent<HealthScript>()*/)
        {
            col.gameObject.GetComponent<HealthScript>().TakeDamage(damage);
            print(col.gameObject.GetComponent<HealthScript>().GetHealth());
            Destroy(this.gameObject);
        }
    }
}
