I have a gun working right, and this is probably something simple I’m missing, but here goes. I have tried multiple version and the only one that plays any sound at all plays way too many. Its quite awful. All i want is for it too play the sound and continue to loop it until the gun is not firing anymore. For me it just plays a million sounds at a time. I am using the machine gun sound from the Angry Bots demo. Any ideas?
var firing : boolean = false;
var accuracy : float;
private var bulletCaseGenerator : Transform;
private var bulletTraceGenerator : Transform;
private var muzzleFlashGenerator : Transform;
private var bulletCaseGeneratorScript : bulletCaseGenerator;
private var bulletTraceGeneratorScript : bulletTraceGenerator;
private var muzzleFlashGeneratorScript : muzzleFlashGenerator;
function Start(){
bulletCaseGenerator = transform.Find("bulletCaseGenerator");
bulletTraceGenerator = transform.Find("bulletTraceGenerator");
muzzleFlashGenerator = transform.Find("muzzleFlashGenerator");
bulletCaseGeneratorScript = bulletCaseGenerator.GetComponent("bulletCaseGenerator");
bulletTraceGeneratorScript = bulletTraceGenerator.GetComponent("bulletTraceGenerator");
muzzleFlashGeneratorScript = muzzleFlashGenerator.GetComponent("muzzleFlashGenerator");
firing = false;
//accuracy = 0.9;
}
function Update () {
bulletCaseGeneratorScript.on = firing;
bulletTraceGeneratorScript.on = firing;
muzzleFlashGeneratorScript.on = firing;
bulletTraceGeneratorScript.accuracy = accuracy;
firing = false;
}
function Fire(){
firing = true;
animation.Play("gunFIRE");
audio.Play();
}
function SetAccuracy(accuracyValue : float){
accuracy = accuracyValue;
}