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 GameObject _bullet;
- void Start()
- {
- bullet = (GameObject)this.gameObject;
- source = GetComponent<AudioSource>();
- source.loop = false;
- }
- void OnCollisionEnter(Collider collider)
- {
- switch (collider.tag)
- {
- case "Ring":
- bullet.GetComponent<AudioSource>().PlayOneShot(ShootR);
- _bullet.gameObject.SetActive(false);
- Debug.Log("R");
- break;
- case "Metal":
- bullet.GetComponent<AudioSource>().PlayOneShot(ShootM);
- _bullet.gameObject.SetActive(false);
- Debug.Log("M");
- break;
- case "Plastic":
- bullet.GetComponent<AudioSource>().PlayOneShot(ShootP);
- _bullet.gameObject.SetActive(false);
- Debug.Log("P");
- break;
- case "Glass":
- bullet.GetComponent<AudioSource>().PlayOneShot(ShootG);
- _bullet.gameObject.SetActive(false);
- Debug.Log("G");
- break;
- case "Vidic":
- bullet.GetComponent<AudioSource>().PlayOneShot(ShootV);
- _bullet.gameObject.SetActive(false);
- Debug.Log("V");
- break;
- }
- }
- void OnTriggerEnter(Collision collision1)
- {
- if (collision1.CompareTag("Enemy"))
- {
- e = true;
- }
- }
- void Update()
- {
- if (e == true)
- {
- bullet.GetComponent<AudioSource>().PlayOneShot(ShootE);
- _bullet.gameObject.SetActive(false);
- Debug.Log("E");
- e = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement