public void OnTriggerEnter(Collider other) { if (goodSpawn) { if (other.tag == "Room") { RoomController otherController = other.gameObject.GetComponent <RoomController>(); if (otherController.roomType.ToString() != "Boss") { Destroy(other.gameObject); //dungeonController.bossSpawned = false; //dungeonController.RespawnBoss(); } // Do not try to finalize our spawn if we're being destroyed! otherController.CancelInvoke("FinalizeSpawn"); //Call DungeonController to spawn dead end Destroy(other.gameObject); //dungeonController.exitsLeft.Remove(enterDoor); //dungeonController.bossSpawned = false; //dungeonController.RespawnBoss(); } } else { if (roomType == roomTypeEnum.Boss && other.tag == "Room") { //dungeonController.exitsLeft.Remove(enterDoor); dungeonController.bossSpawned = false; dungeonController.RespawnBoss(); Destroy(gameObject); } } }