Object that blinks from visible to invisible to visible and so on.

How do i make an object (in my case, a muzzle flare) that blinks on an off and so on when a button is pressed?

var flareRotate = 0;
function Update() {
transform.Rotate(0,flareRotate * Time.deltaTime,0);

GetComponent(MeshRenderer).enabled = false;
if (Input.GetButton(“G”)) {
GetComponent(MeshRenderer).enabled = true;
}
}

this is what i have so far.

  1. ignore the flareRotate and the transforms. those are for something unrelated.
  2. The GetConent and mesh renderer and stuff make it visible and invisible

what i want is for it to blink every .1 seconds. like a machine gun!

StartCoroutine( BlinkOn( 0.1f ) ); // Call once in Start()

void IEnumerator BlinkOn( float fTime )
{
     yield new WaitForSeconds ( fTime );
     // Turn mesh on
     StartCoroutine( BlinkOff( 0.1f ) );
}

void IEnumerator BlinkOff( float fTime )
{
     yield new WaitForSeconds ( fTime );
     // Turn mesh off
     StartCoroutine( BlinkOn( 0.1f ) );
}