- Home /
how can i add a gun sound to this script?
so i have a script for a 3rd person shooter game and it work and all but it has no gun shot sound. i need for the script to make the gun shot sound only when im shooting the gun. the shoot button is left click to shoot. can anyone modify this script to make it play a gunshot sound only when shooting?
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;
}
function SetAccuracy(accuracyValue : float){
accuracy = accuracyValue;
}
Comment