// Use this for initialization void Start() { audioSource = GetComponent <AudioSource>(); audioSource.clip = Sounds[Random.Range(0, Sounds.Count)]; audioPlayer = GetComponentInParent <VirtualAudioSource>(); if (playOnAwake) { playSound(); } }
// Use this for initialization virtual public void Start() { //get player inventory for ammo quantity inventory = GetComponentInParent <Inventory>(); anim = GetComponent <WeaponAnimator>(); crosshairImage = transform.root.Find("PlayerUI/Crosshair").gameObject.GetComponent <Image>(); cam = GetComponentInParent <Camera>(); controller = GetComponentInParent <FPSController>(); if (GetComponent <VirtualAudioSource>()) { sound = GetComponent <VirtualAudioSource>(); } else { Debug.Log("This gun has no sound attached"); } controller.speed -= weight; }