Hello,
I'm making a 4 barrel shotgun turret, and basically all I want it to do is fire each barrel one second after one another. Well, when I say fire, I mean for a muzzle flash texture to appear infront of each barrel.
var currentBarrel : int = 0;
var muzzleFlash : GameObject[];
function Awake(){
muzzleFlash[0].gameObject.SetActiveRecursively(false);
muzzleFlash[1].gameObject.SetActiveRecursively(false);
muzzleFlash[2].gameObject.SetActiveRecursively(false);
muzzleFlash[3].gameObject.SetActiveRecursively(false);
}
function Start(){
Timer();
}
function BarrelFlash(){
muzzleFlash[currentBarrel].gameObject.SetActiveRecursively(true);
yield WaitForSeconds(0.1);
muzzleFlash[currentBarrel].gameObject.SetActiveRecursively(false);
}
function Timer(){
while(currentBarrel < 4){
BarrelFlash();
yield WaitForSeconds(0.3);
currentBarrel ++;
}
}
This is nearly working ... it fires all the barrels in the correct sequence, but how do I then repeat it again? So it goes from: Barrel 1 ... then 2 ... then 3 ... then 4, and then just stops, how do I keep looping?
If someone could help me out with this, then I would much appreciate it.
Thanks