Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class BulletSound : MonoBehaviour {
- 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;
- void Start()
- {
- bullet = (GameObject)this.gameObject;
- }
- void Update()
- {
- 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;
- }
- }
- void OnCollisionEnter(Collision bullet)
- {
- if (bullet.CompareTag("Ring"))
- {
- r = true;
- Debug.Log("R");
- }
- if (bullet.CompareTag("Metal"))
- {
- m = true;
- Debug.Log("M");
- }
- if (bullet.CompareTag("Plastic"))
- {
- p = true;
- Debug.Log("P");
- }
- if (bullet.CompareTag("Glass"))
- {
- g = true;
- Debug.Log("G");
- }
- if (bullet.CompareTag("Vidic"))
- {
- v = true;
- Debug.Log("V");
- }
- }
- void OnTriggerEnter(Collider bullet)
- {
- if (bullet.CompareTag("Enemy"))
- {
- e = true;
- Debug.Log("E");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment