private void Update() { //Debug.Log(health.IsAlive()); if (gameObject != null && target != null) { float dist = Vector3.Distance(target.transform.position, transform.position); if (dist < 5f) { isDetonate = true; } if (isDetonate) { agent.isStopped = true; detonateTimer -= Time.deltaTime; if (detonateTimer <= 0) { areaDamage.AreaDamageEffect(); health.DealDamage(99999); Destroy(gameObject); } } else if (!isDetonate) { SetDestination(); } } }