private void OnTriggerEnter(Collider other) { if (other.gameObject.name != "Monster(Clone)") return; //產生爆炸預鑄件 GameObject node1 = Instantiate(bulletExplosion, null); node1.transform.position = this.transform.position; //播放爆炸音效 //注意:爆炸音效要放在爆炸預鑄件prefab,不要放在子彈或主角(因為被destory了,就無法播放音效) node1.GetComponent().Play(); //銷毀玩家,與怪物 Destroy(this.gameObject); Destroy(other.gameObject); }