using UnityEngine;

public class Bullet : MonoBehaviour
{
    public float speed = 10f;

    void Update()
    {
        transform.position += transform.forward * speed * Time.deltaTime;
    }

    private void OnTriggerEnter(Collider other)
    {
        // Trúng khiên
        if (other.CompareTag("Shield"))
        {
            Destroy(gameObject);
            return;
        }

        // Trúng đầu
        if (other.CompareTag("BluePlayer"))
        {
            HitBox hit = other.GetComponent<HitBox>();

            if (hit != null)
            {
                hit.blueplayer.Die();
            }

            Destroy(gameObject);
        }
        if (other.CompareTag("RedPlayer"))
        {
            HitBox hit = other.GetComponent<HitBox>();

            if (hit != null)
            {
                hit.redplayer.Die();
            }

            Destroy(gameObject);
        }
    }
}