using System.Collections; using UnityEngine; public class Bullet : MonoBehaviour { public float force; public float lifetime; // [HideInInspector] public PlayerController player; private void OnEnable() { StartCoroutine(DestroySelf()); } private void Update() { transform.Translate(Vector3.forward * (Time.deltaTime * force)); } private void OnTriggerEnter(Collider other) { if (!other.gameObject.CompareTag("Enemy")) return; // other.gameObject.GetComponent().Hit(); // player.DisableBullet(gameObject); } private IEnumerator DestroySelf() { yield return new WaitForSeconds(lifetime); // player.DisableBullet(gameObject); } }