This commit is contained in:
2026-06-05 22:54:37 +07:00
parent 6f7c4a22b3
commit c14d3c3a95
6 changed files with 80 additions and 1791 deletions

View File

@@ -28,29 +28,27 @@ public class LaserProjectile : MonoBehaviour
// 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<vIHealthController>() != null)
// 1. Kiểm tra nếu trúng Player hoặc đối tượng có Health
var healthController = other.GetComponentInParent<vIHealthController>();
if (other.CompareTag("Player") || healthController != null)
{
var healthController = other.GetComponentInParent<vIHealthController>();
if (healthController != null)
{
Debug.Log($"<color=red>HIT PLAYER!</color> Found health controller on {healthController.gameObject.name}. Applying {damageAmount} damage.");
Debug.Log($"<color=red>HIT PLAYER!</color> 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();
return;
}
// Phá hủy đạn nếu trúng tường, sàn nhà (mọi thứ không phải trigger khác)
// 2. Phá hủy đạn nếu trúng Ground, Tường, hoặc bất kỳ vật thể đặc nào (không phải Trigger)
if (!other.isTrigger)
{
Debug.Log("Laser hit an obstacle (Wall/Floor).");
Debug.Log($"Laser hit solid object: {other.name} (Ground/Obstacle). Destroying.");
Impact();
}
}