void Update() { if (status.IsDead()) { Die(); } else { float distanceToPlayer = (new Vector2(transform.position.x, transform.position.z) - new Vector2(player.position.x, player.position.z)).sqrMagnitude; if (distanceToPlayer < AggroDistance) { Aggro(); } else { DeAggro(); } } }
void OnTriggerEnter(Collider collider) { if (status.IsDead()) { return; } if (collider.gameObject.tag == Helpers.Tags.Player) { collider.gameObject.GetComponent <PlayerDamageManager>().BumpedEnemy(); } }
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)); } } }