void Update() { if (target == null || Vector3.Distance(this.transform.position, target.position) > DistanceToForget) { ReloadComponents(); randomMovement.enabled = true; this.enabled = false; randomMovement.SetNewNavPoint(); } else { if (attackElapsed <= 0) { ShootTarget(); attackElapsed = AttackRate; } attackElapsed -= Time.deltaTime; } }
void StopChasing() { randomMovement.enabled = true; this.enabled = false; randomMovement.SetNewNavPoint(); }