using Invector; using UnityEngine; public class AutoDestroy : MonoBehaviour { public int damageAmount = 30; void Start() { Destroy(gameObject,2f); } // Update is called once per frame private void OnTriggerEnter(Collider other) { // Debug: Log tên và tag của bất cứ thứ gì đạn chạm vào Debug.Log( $"Laser collided with: {other.name} | Tag: {other.tag} | Layer: {LayerMask.LayerToName(other.gameObject.layer)}"); // Kiểm tra nếu trúng Player if (other.CompareTag("Player") || other.GetComponentInParent() != null) { var healthController = other.GetComponentInParent(); if (healthController != null) { Debug.Log( $"HIT PLAYER! Found health controller on {healthController.gameObject.name}. Applying {damageAmount} damage."); var damage = new vDamage(damageAmount); damage.sender = transform; damage.hitPosition = transform.position; healthController.TakeDamage(damage); } // Luôn phá hủy đạn khi trúng Player Impact(); } } private void Impact() { // Phá hủy đạn ngay lập tức Destroy(gameObject); } }