// prg6-13 金幣碰撞偵測&播放音效 using System.Collections; using System.Collections.Generic; using UnityEngine; public class CoinController : MonoBehaviour { // Start is called before the first frame update void Start() { } // Update is called once per frame void OnTriggerEnter2D(Collider2D other) { //Debug.Log("End"); Debug.Log(gameObject.tag + " entered Trigger tagged " + other.gameObject.tag); if (other.gameObject.name == "cat") { Debug.Log(other.gameObject.tag); GetComponent().Play(); //Destroy(gameObject); } } void Update() { } }