主要思路就是禁用當前的collider
void OnTriggerEnter2D(Collider2D col)
{
if (col.tag == "cherry")
{
col.gameObject.GetComponent<BoxCollider2D>().enabled = false;
Destroy(col.gameObject);
collections = collections + 1;
cherText.text = collections.ToString();
Debug.Log("Triggered by Cherry");
}
}
