using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; public class ShellBoom : MonoBehaviour { public UnityEvent onShellAttack = new UnityEvent(); public bool isPlayer = false; public Transform attackTarget; private void OnTriggerEnter(Collider other) { Debug.Log(other.gameObject.name); if (isPlayer && other.tag == "AttackTarget") { onShellAttack?.Invoke(); } DestroyObject(gameObject, 8f); } private void Update() { if (attackTarget != null) { transform.Translate(transform.forward * Time.deltaTime * 70f, Space.World); } } }