Update:EnemyAI, KamikazeAI

This commit is contained in:
manhduyhoang90
2026-06-05 23:18:29 +07:00
parent 7dd6b9ac20
commit e92d06ed54
3 changed files with 101 additions and 48 deletions

View File

@@ -1,16 +1,47 @@
using Invector;
using UnityEngine;
public class AutoDestroy : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
public int damageAmount = 30;
void Start()
{
Destroy(gameObject,2f);
}
// Update is called once per frame
void Update()
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<vIHealthController>() != 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.");
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);
}
}