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

public class bulletScript : MonoBehaviour
{

    public GameObject explosionPrefab;
    private void OnTriggerEnter2D(Collider2D collision)
    {
        var hit = collision.gameObject;

        if (hit.tag == "Enemy")
        {
            var explosion = Instantiate(explosionPrefab, hit.transform.position, transform.rotation);
            Destroy(hit);
            Destroy(explosion, 1f);
            Destroy(gameObject);
        }
    }

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

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