void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Ball")
        {
            if (SceneManager.GetActiveScene().name == "Classic")
            {
                other.GetComponent <PlayerController>().speed += 0.05f;
                op.SpawnObstacle();
            }

            else if (SceneManager.GetActiveScene().name == "Boost")
            {
                GameObject.FindObjectOfType <DrawLine>().speed += 0.05f;
                bop.SpawnObstacle();
            }

            else if (SceneManager.GetActiveScene().name == "Hoop")
            {
                other.GetComponent <PlayerController>().speed += 0.05f;
                hop.SpawnObstacle();
            }

            else if (SceneManager.GetActiveScene().name == "Gap")
            {
                other.GetComponent <PlayerController>().speed += 0.05f;
                gop.SpawnObstacle();
            }

            else if (SceneManager.GetActiveScene().name == "Protect")
            {
                //No need to add speed, speed comes from collision with the line.
                pop.SpawnObstacle();
            }
        }
    }
Example #2
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Ball")
     {
         UIManager.Instance.AddScore();
         other.GetComponent <PlayerController> ().speed += 0.01f;
         hoopObjectPool.SpawnObstacle();
         transform.parent.GetComponent <Animator>().SetTrigger("Score");
     }
 }