i have an annoying problem with a script that i have made, my audio clip of a minigun is 2 seconds long and my script is only playing one and a half gunshot before starting the sound again. i have been playing around for hours now and i cannot figure out the problem. so i have posted my ‘original unmangled’ script to get help with my problem
that would be awesome, thanks
var Rocket_fireRate : float = 0.5;
var fireRate : float = 0.01;
private var nextFire : float = 0.0;
var rocket : GameObject;
var projectile : GameObject;
var MachineGun_sound: AudioClip;
function Start (){
audio.clip = MachineGun_sound;
}
function Update () {
if (Input.GetButton ("Fire1")){
audio.Play();
if (Time.time > nextFire) {
nextFire = Time.time + fireRate;
var prijectile : GameObject =
Instantiate(projectile, transform.position, transform.rotation) as GameObject;
}
}
else{;audio.Stop();}
if (Input.GetButton ("Fire2") && Time.time > nextFire) {
nextFire = Time.time + Rocket_fireRate;
var rocket : GameObject =
Instantiate(rocket, transform.position, transform.rotation) as GameObject;
}
}