Beispiel #1
0
    public void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.tag == "Goal")               // check if trigger is a goal
        {
            if (col.gameObject.name == "LeftGoal")      // if left goal
            {
                //	update score text
                gameScript.AddScoreRight();
            }
            else if (col.gameObject.name == "RightGoal")
            {
                // update score
                gameScript.AddScoreLeft();
            }

            // reset players and ball
            ResetGameField();
        }
    }