Advertisement
KorolevDmitry123

Untitled

Jul 14th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class BulletSound : MonoBehaviour {
  5. public AudioSource source;
  6. private GameObject bullet;
  7. public AudioClip ShootE;
  8. public AudioClip ShootP;
  9. public AudioClip ShootM;
  10. public AudioClip ShootG;
  11. public AudioClip ShootV;
  12. public AudioClip ShootR;
  13. public bool e;
  14. public bool p;
  15. public bool m;
  16. public bool g;
  17. public bool v;
  18. public bool r;
  19. private RaycastHit Hit;
  20. public Transform target;
  21. public Transform plasmHit;
  22. public GameObject _bullet;
  23. void Start()
  24. {
  25. bullet = (GameObject)this.gameObject;
  26. source = GetComponent<AudioSource>();
  27. source.loop = false;
  28. }
  29. void Update()
  30. {
  31. Vector3 Direction = target.TransformDirection(Vector3.forward);
  32. if (Physics.Raycast(target.position, Direction, out Hit, 10.0f))
  33. {
  34. if (Hit.collider.tag == "Enemy")
  35. {
  36. e = true;
  37. _bullet.gameObject.SetActive(false);
  38. Debug.Log("E");
  39. }
  40. if (Hit.collider.tag == "Ring")
  41. {
  42. r = true;
  43. _bullet.gameObject.SetActive(false);
  44. Debug.Log("R");
  45. }
  46. if (Hit.collider.tag == "Metal")
  47. {
  48. m = true;
  49. _bullet.gameObject.SetActive(false);
  50. Debug.Log("M");
  51. }
  52. if (Hit.collider.tag == "Plastic")
  53. {
  54. p = true;
  55. _bullet.gameObject.SetActive(false);
  56. Debug.Log("P");
  57. }
  58. if (Hit.collider.tag == "Glass")
  59. {
  60. g = true;
  61. _bullet.gameObject.SetActive(false);
  62. Debug.Log("G");
  63. }
  64. if (Hit.collider.tag == "Vidic")
  65. {
  66. v = true;
  67. _bullet.gameObject.SetActive(false);
  68. Debug.Log("V");
  69. }
  70. //Quaternion HitRotation = Quaternion.FromToRotation(Vector3.up, Hit.normal);
  71. //Instantiate(plasmHit, Hit.point+(Hit.normal*0.001f), HitRotation);
  72. //if (Hit.collider.material.staticFriction == 0.2f)
  73. //{
  74. // Instantiate(plasmHit, Hit.point+(Hit.normal*0.001f), HitRotation);
  75. //}
  76. }
  77. if (r == true)
  78. {
  79. bullet.GetComponent<AudioSource>().PlayOneShot(ShootR);
  80. r = false;
  81. }
  82. if (m == true)
  83. {
  84. bullet.GetComponent<AudioSource>().PlayOneShot(ShootM);
  85. m = false;
  86. }
  87. if (p == true)
  88. {
  89. bullet.GetComponent<AudioSource>().PlayOneShot(ShootP);
  90. p = false;
  91. }
  92. if (g == true)
  93. {
  94. bullet.GetComponent<AudioSource>().PlayOneShot(ShootG);
  95. g = false;
  96. }
  97. if (v == true)
  98. {
  99. bullet.GetComponent<AudioSource>().PlayOneShot(ShootV);
  100. v = false;
  101. }
  102. if (e == true)
  103. {
  104. bullet.GetComponent<AudioSource>().PlayOneShot(ShootE);
  105. e = false;
  106. }
  107. }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement