Delay in setting Boolean Value

I am making a portal that will need to have a delay to set a boolean to control whether or not they can be used. I am coming over from Unreal to Unity and in Unreal, you have a delay node for these kinds of operations. I have tried to use a Wait For Seconds method and have had troubles with it.

	void  ResetCanTP (float delay)
	{
		CanTP = false;
		yield WaitForSeconds(delay);
		CanTP = true;
	}

}

The error I am seeing is: Expected ; or = ( cannot specify arguments in declaration)
No idea how to fix this issue as I am new to Unity and C#

You could invoke a switch.

In your main code, assuming switchBool is already set to false by default, you could do something like this in the Start(), so it happens 2 seconds after creating the object:

Invoke("delayedSwitch",2.0f);

Then a method:

public void delayedSwitch ()
{
    switchBool=true;
}

This would mean the script is attached to the portal GameObject, and the switchBool is a variable in the same script.

Not sure if this is the approach you are looking for, but this is one approach that may work for you.

You need to change ‘void’ to ‘IEnumerator’

Then call StartCoroutine(ResetCanTP(2f));

And also change your yield line to

yield return new WaitForSeconds(delay);