Advertisement
KorolevDmitry123

Untitled

Jul 14th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 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. void Start()
  23. {
  24. bullet = (GameObject)this.gameObject;
  25. source = GetComponent<AudioSource>();
  26. source.loop = false;
  27. }
  28. void Update()
  29. {
  30. Vector3 Direction = target.TransformDirection(Vector3.forward);
  31. if (Physics.Raycast(target.position, Direction, out Hit, 500f)) ///////////////////
  32. {
  33. Debug.Log("111");
  34. Quaternion HitRotation = Quaternion.FromToRotation(Vector3.up, Hit.normal);
  35. if (Hit.collider.material.staticFriction == 0.2f)
  36. {
  37. Instantiate(plasmHit, Hit.point+(Hit.normal*0.001f), HitRotation);
  38. }
  39. }
  40. if (r == true)
  41. {
  42. bullet.GetComponent<AudioSource>().PlayOneShot(ShootR);
  43. r = false;
  44. }
  45. if (m == true)
  46. {
  47. bullet.GetComponent<AudioSource>().PlayOneShot(ShootM);
  48. m = false;
  49. }
  50. if (p == true)
  51. {
  52. bullet.GetComponent<AudioSource>().PlayOneShot(ShootP);
  53. p = false;
  54. }
  55. if (g == true)
  56. {
  57. bullet.GetComponent<AudioSource>().PlayOneShot(ShootG);
  58. g = false;
  59. }
  60. if (v == true)
  61. {
  62. bullet.GetComponent<AudioSource>().PlayOneShot(ShootV);
  63. v = false;
  64. }
  65. if (e == true)
  66. {
  67. bullet.GetComponent<AudioSource>().PlayOneShot(ShootE);
  68. e = false;
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement