private void Update() { aliveTime += Time.deltaTime; if (EnemyShooting.DistanceBetween(this.gameObject.transform.position, GameObject.FindGameObjectWithTag("Player").transform.position) > despawnDistance || aliveTime > aliveDuration) { Destroy(this.gameObject); } }