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;
- private RaycastHit Hit;
- public Transform target;
- public Transform plasmHit;
- public GameObject _bullet;
- void Start()
- {
- bullet = (GameObject)this.gameObject;
- source = GetComponent<AudioSource>();
- source.loop = false;
- }
- void Update()
- {
- Vector3 Direction = target.TransformDirection(Vector3.forward);
- if (Physics.Raycast(target.position, Direction, out Hit, 10.0f))
- {
- if (Hit.collider.tag == "Enemy")
- {
- e = true;
- _bullet.gameObject.SetActive(false);
- Debug.Log("E");
- }
- if (Hit.collider.tag == "Ring")
- {
- r = true;
- _bullet.gameObject.SetActive(false);
- Debug.Log("R");
- }
- if (Hit.collider.tag == "Metal")
- {
- m = true;
- _bullet.gameObject.SetActive(false);
- Debug.Log("M");
- }
- if (Hit.collider.tag == "Plastic")
- {
- p = true;
- _bullet.gameObject.SetActive(false);
- Debug.Log("P");
- }
- if (Hit.collider.tag == "Glass")
- {
- g = true;
- _bullet.gameObject.SetActive(false);
- Debug.Log("G");
- }
- if (Hit.collider.tag == "Vidic")
- {
- v = true;
- _bullet.gameObject.SetActive(false);
- Debug.Log("V");
- }
- //Quaternion HitRotation = Quaternion.FromToRotation(Vector3.up, Hit.normal);
- //Instantiate(plasmHit, Hit.point+(Hit.normal*0.001f), HitRotation);
- //if (Hit.collider.material.staticFriction == 0.2f)
- //{
- // Instantiate(plasmHit, Hit.point+(Hit.normal*0.001f), HitRotation);
- //}
- }
- 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