using System.Collections; using System.Collections.Generic; using UnityEngine; [System.Serializable] public class CoinScript : MonoBehaviour { public GameHandler GH; public AudioClip coinSound; void Start() { GH = GameObject.Find("CoinCanvas").GetComponent(); } // Update is called once per frame void Update() { transform.Rotate(0, 0, 10); } private void OnTriggerEnter(Collider other) { GH.coins++; AudioSource.PlayClipAtPoint(coinSound, transform.position); Destroy(gameObject); } }