Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Box : MonoBehaviour
  6. {
  7. AudioSource audioSource;
  8.  
  9. public AudioClip brick;
  10. public AudioClip glass;
  11.  
  12. void Start()
  13. {
  14. audioSource = GetComponent<AudioSource>();
  15. }
  16.  
  17. private void OnCollisionEnter(Collision collision)
  18. {
  19. if (collision.gameObject.tag == "Brick")
  20. {
  21. audioSource.clip = brick;
  22. audioSource.Play();
  23. }
  24.  
  25. if (collision.gameObject.tag == "Glass")
  26. {
  27. audioSource.clip = glass;
  28.  
  29. audioSource.Play();
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement