private void OnTriggerStay(Collider other) { if (other.tag == "Player") { Vector3 newTarget = new Vector3(other.transform.position.x + 0.3f, other.transform.position.y + 1, other.transform.position.z); target = other.transform; float distance = Vector3.Distance(transform.position, target.position); if (distance > shotDistance) { transform.LookAt(newTarget); FollowTarget(); } else if (distance <= shotDistance) { transform.LookAt(newTarget); if (isAttacking == false) { GameObject GO = Instantiate(atkPrefab, atkOrigin.position, atkOrigin.rotation); EnemyShootController esc = GO.GetComponent <EnemyShootController>(); esc.SetStart(atkDamage, atkSpeed); isAttacking = true; } } } }
void Start() { body = GetComponent <Rigidbody> (); shootComponent = GetComponentInChildren <EnemyShootController> (); PatternSwitch(); }
void OnShoot(EnemyShootController ctrl) { state = (int)State.Attack; }