// Update is called once per frame void Update() { if (Physics.Raycast(da.ray, out hit)) { if (GameObject.FindGameObjectsWithTag("hitCube").Length <= 1) { switch (hit.transform.gameObject.tag) { case "hitCube": fixCountDown -= Time.deltaTime; if (fixCountDown < 0f) { DestroyCube(); } break; case "Finish": sc.Result(); break; case "Respawn": sc.DestroyAllCubes(true); break; default: fixCountDown = timeToFix; break; } } else { if (hit.transform.gameObject.tag == "Respawn") { sc.DestroyAllCubes(true); fixCountDown = timeToFix; } if (hit.transform.gameObject.tag == "Resume") { sc.DestroyAllCubes(); fixCountDown = timeToFix; } } } }