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;
- 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, 500f)) ///////////////////
- {
- Debug.Log("111");
- Quaternion HitRotation = Quaternion.FromToRotation(Vector3.up, Hit.normal);
- 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