hi guys, im trying to get a sound to play when the gun shot is fired, i think i am getting the hang of java script but i am getting errors and no sound
(MissingMethodException: Method not found: ‘UnityEngine.AudioSource.play’.)
here is the code i am using to fire the cannons
var projectile : Rigidbody;
var speed = 20;
var gunSound : AudioSource;
function Update () {
if(Input.GetButtonDown(“Fire1”)) {
clone = Instantiate(projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection( Vector3 (0, 0, speed));
gunSound.play();
Destroy (clone.gameObject, 2);
}
}