How do I switch a bool every two seconds?

How do I make a bool switch between true and false every two seconds?

var thatBoolean : boolean;

function Awake (){
    InvokeRepeating("Switch", 0, 2);

function Switch (){
    thatBoolean = !thatBoolean;

There you go.

Hi! this is my first answer so please be gentle with me people :wink:

function Update()
whatever = false;
yield WaitForSeconds (2);
whatever = true;

Hope it helps :slight_smile:


var isToggling : boolean = false;
var ToggleOnOff : boolean = false;
function Update(){
if (!isToggling){

function Toggle(){
 isToggling = true;
 ToggleOnOff = true;
  yield WaitforSeconds(2);
 ToggleOnOff = false;
  yield WaitforSeconds(2);
 isToggling = false;

That will toggle it on, wait for 2 secs, toggle it off, wait 2 secs more, then loops