Advertisement
Guest User

1

a guest
Apr 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class SoundOnCollision : MonoBehaviour
  5. {
  6.  
  7. public AudioClip zvuk;
  8.  
  9. void Start()
  10. {
  11.  
  12. GetComponent<AudioSource>().clip = zvuk;
  13.  
  14. }
  15.  
  16. void OnCollisionEnter (Collision col)
  17. {
  18. if(col.gameObject.name == "floor")
  19. {
  20.  
  21. GetComponent<AudioSource>().Play ();
  22.  
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement