[Unity2d]吃錢、金幣程式碼

 

簡單就進入他的區域觸發解構子@_@

    void OnCollisionEnter2D(Collision2D coll) {
        if (coll.gameObject.tag == "Coin") {
            Destroy(coll.gameObject);
        }
        
    }

參考:http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnCollisionEnter2D.html