using UnityEngine; public class Bullet : MonoBehaviour { public float speed = 20f; void Update() { transform.Translate(Vector3.forward * speed * Time.deltaTime); Destroy(gameObject, 3f);// Destroy bullet after 3s } void OnTriggerEnter(Collider other) { if (other.CompareTag("Target")) { other.GetComponent().TakeDamage(); Destroy(gameObject); } } }