Update
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user