void OnCollisionEnter(Collision other) { //Tell the TestScript to stop rotating testScript ts = GameObject.Find("Sphere").GetComponent <testScript>(); ts.stopRotation(); //Tell the Timer script to stop counting Timer timer = GameObject.Find("Plane").GetComponent <Timer>(); timer.stopTimer(); ballHit = true; print("Ball hit the board"); print(string.Format("Ball Hit situation is {0}:", ballHit)); GameObject smashed = Instantiate(smashedBullet, transform.position, Quaternion.identity) as GameObject; GameControl gameControl = GameObject.Find("Board").GetComponent <GameControl>(); Destroy(this.gameObject); smashed.name = "smashed"; gameControl.collisionHappenedDoSth(); }
// Update is called once per frame void Update() { if (timeToReset) { timeRemaining = 6; timeIsUp = false; timeToFreeze = false; timeToReset = false; return; } if (timeToFreeze) { return; } //Tell the TestScript to stop rotating if timer goes to zero testScript ts = GameObject.Find("Sphere").GetComponent <testScript>(); //Tell the board in GameControl to stop rotating if timer goes to zero GameControl gc = GameObject.Find("Board").GetComponent <GameControl>(); //print the time remaining with 2 digits only timer.text = timeRemaining.ToString("f2"); if (timeRemaining >= minTime) { startTimer(); } else if (timeRemaining <= 0 && !timeIsUp) { print("time is up"); timeIsUp = true; gc.wrongAnswer += 1; gc.wrongShot.text = gc.wrongAnswer.ToString(); gc.timeIsUp(); ts.stopRotation(); } }