void Aggro() { navAgent.SetDestination(player.position); if (status.IsDead() || status.IsAggro()) { return; } status.AggroOnPlayer(); navAgent.Resume(); }
void Update() { if (status.IsDead()) { Die(); } else if (status.IsFrozen()) { return; } else { if (lastShotTime > 0) { lastShotTime -= Time.deltaTime; } float distanceToPlayer = (transform.position - player.position).sqrMagnitude; if (distanceToPlayer < AggroDistance) { Aggro(); } else { DeAggro(); } if (lastShotTime <= 0 && status.IsAggro()) { Shoot(); } if (status.IsAggro()) { transform.LookAt(new Vector3(player.position.x, transform.position.y, player.position.z)); } } }