예제 #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.name == "Ball")
        {
            BallCollision        = GameObject.Find("Ball");
            ballCollisionChecker = BallCollision.transform.GetChild(0).gameObject.GetComponent <BallCollisionChecker>();

            string LastTouchPlayer = ballCollisionChecker.LastTouchPlayer;
            Debug.Log("Goal by " + LastTouchPlayer);

            WinnerUI.SetActive(true);
            WinnerUI.transform.GetChild(0).GetComponent <Text>().text = LastTouchPlayer + " Scored!";
        }
    }
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Ball")
        {
            try
            {
                ballCollision        = GameObject.Find("Ball");
                ballCollisionChecker = ballCollision.transform.GetChild(0).gameObject.GetComponent <BallCollisionChecker>();
            }
            catch
            {
                ballCollision        = GameObject.Find("Ball(Clone)");
                ballCollisionChecker = ballCollision.transform.GetChild(0).gameObject.GetComponent <BallCollisionChecker>();
            }

            string lastTouchPlayer = ballCollisionChecker.lastTouchPlayer;
            Debug.Log("Goal by " + lastTouchPlayer);

            winnerUI.SetActive(true);
            winnerUI.transform.GetChild(0).GetComponent <Text>().text = lastTouchPlayer + " Scored!";
        }
    }