Advertisement
Guest User

Untitled

a guest
May 5th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #pragma strict
  2.  
  3. public var coinEffect : GameObject;
  4. private var soundFX : AudioSource;
  5.  
  6. function Start()
  7. {
  8. soundFX = GetComponent.<AudioSource>();
  9.  
  10. }
  11.  
  12. function OnTriggerEnter2D (other : Collider2D)
  13. {
  14. if (other.CompareTag("Player"))
  15. {
  16. if (coinEffect)
  17. Instantiate(coinEffect, transform.position, transform.rotation);
  18.  
  19. if (soundFX)
  20. {
  21. print("playing AudioSource");
  22. soundFX.Play();
  23. }
  24.  
  25. //gameObject.renderer.enabled = false; // only works in Unity 4.x
  26. gameObject.GetComponent.<Renderer>().enabled = false; // will work in Unity 4 & 5
  27. Destroy(gameObject, 1);
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement