Guest User

Untitled

a guest
Jul 5th, 2016
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class BulletSound : MonoBehaviour {
  5. private GameObject bullet;
  6. public AudioClip ShootE;
  7. public AudioClip ShootP;
  8. public AudioClip ShootM;
  9. public AudioClip ShootG;
  10. public AudioClip ShootV;
  11. public AudioClip ShootR;
  12. public bool e;
  13. public bool p;
  14. public bool m;
  15. public bool g;
  16. public bool v;
  17. public bool r;
  18. void Start()
  19. {
  20. bullet = (GameObject)this.gameObject;
  21. }
  22. void Update()
  23. {
  24. if (r == true)
  25. {
  26. bullet.GetComponent<AudioSource>().PlayOneShot(ShootR);
  27. r = false;
  28. }
  29. if (m == true)
  30. {
  31. bullet.GetComponent<AudioSource>().PlayOneShot(ShootM);
  32. m = false;
  33. }
  34. if (p == true)
  35. {
  36. bullet.GetComponent<AudioSource>().PlayOneShot(ShootP);
  37. p = false;
  38. }
  39. if (g == true)
  40. {
  41. bullet.GetComponent<AudioSource>().PlayOneShot(ShootG);
  42. g = false;
  43. }
  44. if (v == true)
  45. {
  46. bullet.GetComponent<AudioSource>().PlayOneShot(ShootV);
  47. v = false;
  48. }
  49. if (e == true)
  50. {
  51. bullet.GetComponent<AudioSource>().PlayOneShot(ShootE);
  52. e = false;
  53. }
  54. }
  55. void OnCollisionEnter(Collision bullet)
  56. {
  57. if (bullet.CompareTag("Ring"))
  58. {
  59. r = true;
  60. Debug.Log("R");
  61. }
  62. if (bullet.CompareTag("Metal"))
  63. {
  64. m = true;
  65. Debug.Log("M");
  66. }
  67. if (bullet.CompareTag("Plastic"))
  68. {
  69. p = true;
  70. Debug.Log("P");
  71. }
  72. if (bullet.CompareTag("Glass"))
  73. {
  74. g = true;
  75. Debug.Log("G");
  76. }
  77. if (bullet.CompareTag("Vidic"))
  78. {
  79. v = true;
  80. Debug.Log("V");
  81. }
  82.  
  83. }
  84. void OnTriggerEnter(Collider bullet)
  85. {
  86. if (bullet.CompareTag("Enemy"))
  87. {
  88. e = true;
  89. Debug.Log("E");
  90. }
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment