Exemple #1
0
 public void OnCollisionEnter2D(Collision2D other)
 {
     if (other.gameObject.CompareTag("Player"))
     {
         sound.pickUpSound(.5f);
     }
     Destroy(gameObject);
 }
Exemple #2
0
 // manage the collision between this object and other object
 void OnCollisionEnter2D(Collision2D other)
 {
     if (other.gameObject.CompareTag("Player")) // if this object collide with the player
     {
         sound.pickUpSound(.5f);                // play the sound of the pick up
         Destroy(gameObject);                   // then destroy this object
     }
 }