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