Esempio n. 1
0
 void OnTriggerEnter2D(Collider2D other)                                  //method for collision detection
 {
     if (other.tag == "Player")                                           //if the player collides with the object
     {
         hud = GameObject.Find("Main Camera").GetComponent <HUDscript>(); //find the hudscript in the 'main camera' object
         hud.IncreaseScore(10);                                           //increase the score
         Destroy(this.gameObject);                                        //destroy this object
     }
 }
 void OnTriggerEnter2D(Collider2D other)//method for collision detection
 {
     if (other.tag == "Player")//if the player collides with the object
     {
         hud = GameObject.Find("Main Camera").GetComponent<HUDscript>();//find the hudscript in the 'main camera' object
         hud.IncreaseScore(10);//increase the score
         Destroy (this.gameObject);//destroy this object
     }
 }
Esempio n. 3
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            hud = GameObject.Find("Main Camera").GetComponent <HUDscript>();
            hud.IncreaseScore(10);
            gameObject.GetComponent <SpriteRenderer>().enabled = false;
            Destroy(this.gameObject, 3f);

            if (Settings.MusicSettings.IsMusicOn)
            {
                gameObject.GetComponent <AudioSource>().Play();
            }
        }
    }