void Update() { if (onTunnelL && onTunnelR) // Game has started, raise flag and start Scrolling { scrollRef.ScrollCamera(); gameStarted = true; } Cast(); // call the cast function, which checks for fingers colliding with tunnels int numTouches = Input.touchCount; // get number of fingers on screen scorePoints(); if (gameStarted == true) // if game has started, if you let go of one tunnel game has ended { if (!onTunnelL || !onTunnelR) { gameHasEnded = true; resetButton.SetActive(true); scrollRef.Stop(); //User lost, stop scrolling & scoring } if (numTouches != 2) // if game started, and you raise one of your fingers, game ended { gameHasEnded = true; resetButton.SetActive(true); scrollRef.Stop(); //User lost, stop scrolling & scoring } } if (numTouches == 0) { finger1GO.SetActive(false); finger2GO.SetActive(false); } if (numTouches > 0) { for (int i = 0; numTouches > i; i++) { Touch touch = Input.GetTouch(i); if (touch.fingerId == 0) { Vector2 touchPos = Camera.main.ScreenToWorldPoint(touch.position); finger1GO.SetActive(true); finger1GO.transform.position = touchPos; } if (touch.fingerId == 1) { Vector2 touchPos = Camera.main.ScreenToWorldPoint(touch.position); finger2GO.SetActive(true); finger2GO.transform.position = touchPos; } } } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.name == "DEATH") { m_Camerascroll.Stop(); } }