Facebook
From asfasf, 3 Years ago, written in C#.
Embed
Download Paste or View Raw
Hits: 147
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. [System.Serializable]
  6. public class CoinScript : MonoBehaviour
  7. {
  8.     public GameHandler GH;
  9.     public AudioClip coinSound;
  10.  
  11.     void Start()
  12.     {
  13.         GH = GameObject.Find("CoinCanvas").GetComponent<GameHandler>();
  14.     }
  15.  
  16.     // Update is called once per frame
  17.     void Update()
  18.     {
  19.         transform.Rotate(0, 0, 10);
  20.     }
  21.  
  22.     private void OnTriggerEnter(Collider other)
  23.     {
  24.         GH.coins++;
  25.         AudioSource.PlayClipAtPoint(coinSound, transform.position);
  26.         Destroy(gameObject);
  27.     }
  28. }
  29.