I have a script for shooting my gun (you can have if you wish) I need to make it so i can add a audio to this script like a gun shot sound
Script /
var prefabBullet:Transform;
var shootForce:float;
function Update()
{
if(Input.GetButtonDown("Fire1"))
{
var instanceBullet = Instantiate(prefabBullet, transform.position, Quaternion.identity);
instanceBullet.rigidbody.AddForce(transform.forward * shootForce);
}
}
Add an audioSource to your gun, drag the sound you want to shootSound in the Inspector and fire the sound using:
var shootSound:AudioClip;
function Update(){
if (Input.GetButtonDown("Fire1")){
audio.PlayOneShot(shootSound);
var instanceBullet = Instantiate(prefabBullet, transform.position, Quaternion.identity);
instanceBullet.rigidbody.AddForce(transform.forward * shootForce);
}
}
I edited the script a little just for the sound. I did this:
var shootSound:AudioClip;
function Update(){
if (Input.GetButtonDown(“Fire1”)){
} audio.PlayOneShot(shootSound)};
Now I get a bunch of errors. What did I do wrong?