private void OnTriggerEnter(Collider other) { //적이랑 닿으면 camera 움직임 if (other.gameObject.tag == "chicken_enemy" && tiger.is_basic_attack && tiger.is_target_chicken) { E_chicken = GameObject.FindWithTag("chicken_enemy").GetComponent <E_ch_Attack>(); E_chicken.hpMove(tiger.attack); tiger.is_Attack = true; } if (other.gameObject.tag == "tiger_enemy" && tiger.is_basic_attack && tiger.is_target_tiger) { E_tiger = GameObject.FindWithTag("tiger_enemy").GetComponent <E_t_Attack>(); E_tiger.hpMove(tiger.attack); tiger.is_Attack = true; } if (other.gameObject.tag == "cow_enemy" && tiger.is_basic_attack && tiger.is_target_cow) { E_cow = GameObject.FindWithTag("cow_enemy").GetComponent <E_cow_Attack>(); E_cow.hpMove(tiger.attack); tiger.is_Attack = true; } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "chicken_enemy" && (cow.is_basic_attack || cow.is_special_attack_time) && cow.is_target_chicken) //충돌+(기본공격 or 고유공격 중) { E_chicken = GameObject.FindWithTag("chicken_enemy").GetComponent <E_ch_Attack>(); E_chicken.hpMove(cow.attack); //Debug.Log("소 공격력: "+cow.attack); cow.is_Attack = true; camera_shake = true; } if (other.gameObject.tag == "tiger_enemy" && (cow.is_basic_attack || cow.is_special_attack_time) && cow.is_target_tiger) { cow.is_Attack = true; camera_shake = true; } if (other.gameObject.tag == "cow_enemy" && (cow.is_basic_attack || cow.is_special_attack_time) && cow.is_target_cow) { E_cow = GameObject.FindWithTag("cow_enemy").GetComponent <E_cow_Attack>(); E_cow.hpMove(cow.attack); cow.is_Attack = true; camera_shake = true; } }
private void OnTriggerEnter(Collider other) { Vector3 pos; //적이랑 닿으면 camera 움직임 if (other.gameObject.tag == "chicken_enemy") { E_chicken = GameObject.FindWithTag("chicken_enemy").GetComponent <E_ch_Attack>(); chicken.is_Attack = true; camera_shake = true; if (!attacked) //중복 방지 { if (chicken.is_go_right) //적이 왼쪽 이면 { pos = new Vector3(other.transform.position.x - 1, other.transform.position.y, other.transform.position.z); } else//적이 오른쪽이면 { pos = new Vector3(other.transform.position.x + 1, other.transform.position.y, other.transform.position.z); } transform.position = Vector3.MoveTowards(other.transform.position, pos, 0.1f); E_chicken.hpMove(chicken.attack); if (E_chicken.hp <= 0) { camera_shake = false; } attacked = true; } } if (other.gameObject.tag == "tiger_enemy") { E_tiger = GameObject.FindWithTag("tiger_enemy").GetComponent <E_t_Attack>(); chicken.is_Attack = true; camera_shake = true; if (!attacked) //중복 방지 { if (chicken.is_go_right) //적이 왼쪽 이면 { pos = new Vector3(other.transform.position.x - 1, other.transform.position.y, other.transform.position.z); } else//적이 오른쪽이면 { pos = new Vector3(other.transform.position.x + 1, other.transform.position.y, other.transform.position.z); } transform.position = Vector3.MoveTowards(other.transform.position, pos, 0.1f); E_tiger.hpMove(chicken.attack); if (E_tiger.hp <= 0) { camera_shake = false; } attacked = true; } } if (other.gameObject.tag == "cow_enemy") { E_cow = GameObject.FindWithTag("cow_enemy").GetComponent <E_cow_Attack>(); chicken.is_Attack = true; camera_shake = true; if (!attacked) //중복 방지 { if (chicken.is_go_right) //적이 왼쪽 이면 { pos = new Vector3(other.transform.position.x - 1, other.transform.position.y, other.transform.position.z); } else//적이 오른쪽이면 { pos = new Vector3(other.transform.position.x + 1, other.transform.position.y, other.transform.position.z); } transform.position = Vector3.MoveTowards(other.transform.position, pos, 0.1f); E_cow.hpMove(chicken.attack); if (E_cow.hp <= 0) { camera_shake = false; } attacked = true; } } }