void OnTriggerEnter(Collider collider) { if (collider.gameObject.tag == "enemy") { GameObject hitTemp = Instantiate(hitEffect, transform.position, Quaternion.identity); Destroy(hitTemp, 1); Destroy(collider.gameObject); towerHealth -= 20; healthBar.value = towerHealth; if (towerHealth == 0) { StartCoroutine(EnemySpawn.WaitForRestart()); gameObject.transform.localScale = new Vector3(0, 0, 0); } } if (collider.gameObject.tag == "boss") { GameObject hitTemp = Instantiate(hitEffect, transform.position, Quaternion.identity); Destroy(hitTemp, 1); Destroy(collider.gameObject); towerHealth = 0; healthBar.value = towerHealth; StartCoroutine(EnemySpawn.WaitForRestart()); gameObject.transform.localScale = new Vector3(0, 0, 0); } }