This question was
closed Jan 09, 2016 at 12:50 AM by
piercegov for the following reason:
For some reason, restarting unity fixed it.
Question by
piercegov · Jan 08, 2016 at 10:05 AM ·
javascriptgun
Muzzle flash script not working properly
Hi all,
For some reason this code here doesn't work and I have no clue why:
function muzzleFlash () {
gameObject.GetComponent(Light).enabled = true;
gameObject.GetComponent(SpriteRenderer).enabled = true;
yield WaitForSeconds (0.1);
gameObject.GetComponent(Light).enabled = false;
gameObject.GetComponent(SpriteRenderer).enabled = false;
}
Whenever I use this, absolutely nothing happens when i shoot. (Note that I have these components disabled in the start). However, when I put these in opposite order (as in false goes first) it works but inversely, with the light flickering off to be on otherwise. How come it doesn't work at all this way?
Comment