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?
↧