コード例 #1
0
 void OnTriggerEnter2D(Collider2D coll)         //when this gameobject encounters a collision with another gameobject
 {
     if (coll.gameObject.name.Equals("player")) //if coll, the object that collided with this game object has the name of "player" <- that is case sensitive
     {
         CoinCounter.addToCoins();              //this calls the static method 'addToCoins' from the CoinCouter script
         Destroy(this.gameObject);              //deletes the coin from the scene
     }
 }