Advertisement
LegitTeddyBears

BadSound

Jun 3rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class GunSound : MonoBehaviour {
  6. //Note this is a terrible way to add sound please don't do this unless you have completely run out of ideas
  7.     public AudioSource Audio1;
  8.     public AudioSource Audio2;
  9.  
  10.     //refers to the weapon script to see if we can fire
  11.     public Weapon OSA2;
  12.  
  13.     //refers to the Bomb script to see if we have ammo
  14.     public Bomb OSA;
  15.     // Use this for initialization
  16.     void Start ()
  17.     {
  18.         //Get the Script!
  19.         OSA = OSA.GetComponent<Bomb>();
  20.     }
  21.    
  22.     // Update is called once per frame
  23.     void Update ()
  24.     {
  25.         if (Input.GetMouseButtonDown(0))
  26.         {
  27.            
  28.             Audio1.Play();
  29.         }
  30.  
  31.         if (OSA.Ammo != 0)
  32.         {
  33.  
  34.             if (Input.GetMouseButtonDown(1))
  35.             {
  36.                
  37.                 Audio2.Play();
  38.             }
  39.         }
  40.      }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement