Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class BulletSound : MonoBehaviour {
- public AudioSource source;
- private GameObject bullet;
- public AudioClip ShootE;
- public AudioClip ShootP;
- public AudioClip ShootM;
- public AudioClip ShootG;
- public AudioClip ShootV;
- public AudioClip ShootR;
- public bool e;
- public bool p;
- public bool m;
- public bool g;
- public bool v;
- public bool r;
- public GameObject _bullet;
- void Start()
- {
- bullet = (GameObject)this.gameObject;
- source = GetComponent<AudioSource>();
- source.loop = false;
- }
- void Update()
- {
- switch ( )
- {
- case "Enemy":
- e = true;
- _bullet.gameObject.SetActive(false);
- Debug.Log("E");
- break;
- case "Ring":
- r = true;
- _bullet.gameObject.SetActive(false);
- Debug.Log("R");
- break;
- case "Metal":
- m = true;
- _bullet.gameObject.SetActive(false);
- Debug.Log("M");
- break;
- case "Plastic":
- p = true;
- _bullet.gameObject.SetActive(false);
- Debug.Log("P");
- break;
- case "Glass":
- g = true;
- _bullet.gameObject.SetActive(false);
- Debug.Log("G");
- break;
- case "Vidic":
- v = true;
- _bullet.gameObject.SetActive(false);
- Debug.Log("V");
- break;
- }
- if (r == true)
- {
- bullet.GetComponent<AudioSource>().PlayOneShot(ShootR);
- r = false;
- }
- if (m == true)
- {
- bullet.GetComponent<AudioSource>().PlayOneShot(ShootM);
- m = false;
- }
- if (p == true)
- {
- bullet.GetComponent<AudioSource>().PlayOneShot(ShootP);
- p = false;
- }
- if (g == true)
- {
- bullet.GetComponent<AudioSource>().PlayOneShot(ShootG);
- g = false;
- }
- if (v == true)
- {
- bullet.GetComponent<AudioSource>().PlayOneShot(ShootV);
- v = false;
- }
- if (e == true)
- {
- bullet.GetComponent<AudioSource>().PlayOneShot(ShootE);
- e = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement