void Update() { if (entityComponent.enabled) { targets = attackComponent.FindTargets(true, 10); if (targets.Count > 0) { PointAt(targets[0]); fireCooldownLeft -= Time.deltaTime; if (fireCooldownLeft <= 0 && direction.magnitude <= range) { fireCooldownLeft = fireCooldown; Fire(targets[0], projectilePrefab); } } } }
void FindTarget() { targetsList = attackComponent.FindTargets(false, 20); }