//射撃 void Shoot() { //エフェクト for (int i = 0; i < 4; i++) { bullets = Instantiate(bullet) as GameObject; bullets.transform.position = fpsCamera_s[i].transform.position; bullets.transform.rotation = fpsCamera.transform.rotation; Destroy(bullets, 1f); } //レーザー射撃 Ray ray = fpsCamera.ScreenPointToRay(center); RaycastHit hit; //rayがhitした場合 if (Physics.Raycast(ray, out hit, 80f)) { if (hit.collider.gameObject.tag == "Enemy") { EH = hit.collider.GetComponent <EnemyHp>(); EH.EnemyDamage(laserDamage); Destroy(bullets, 0.4f); } } }
void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "Enemy") { Destroy(gameObject); var hitEf = Instantiate(Ef_explosion, other.transform); Destroy(hitEf, 1f); EH = other.collider.GetComponent <EnemyHp>(); EH.EnemyDamage(missileDamage); } }