Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma strict
- public var coinEffect : GameObject;
- private var soundFX : AudioSource;
- function Start()
- {
- soundFX = GetComponent.<AudioSource>();
- }
- function OnTriggerEnter2D (other : Collider2D)
- {
- if (other.CompareTag("Player"))
- {
- if (coinEffect)
- Instantiate(coinEffect, transform.position, transform.rotation);
- if (soundFX)
- {
- print("playing AudioSource");
- soundFX.Play();
- }
- //gameObject.renderer.enabled = false; // only works in Unity 4.x
- gameObject.GetComponent.<Renderer>().enabled = false; // will work in Unity 4 & 5
- Destroy(gameObject, 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement