Opening and closing?

Hey Im trying to make a script where a jaw opens and closes every two seconds This is stays open for two - and closes for two

I don’t care if opening it is lerped or just instant but i cant seem to get the (C#) code to work.

using UnityEngine;
using System.Collections;

public class Jaw : MonoBehaviour {
private bool open;

void OC() {
	open = !open;
void Example() {
	InvokeRepeating("OC", 2, 2F);

void Update () {
		if (open) {
       //open jaw
		Debug.Log ("open");

		else {
    // close jaw
		Debug.Log ("not open");

(so far it just debugs “not open” every frame lol)

Thanks in advance

bool open= false ;
IEnumerator Start()

yield return new WaitForSeconds (2f);
print (open);
open= !open
open= true;

Hope you understood it and it will work.

This is a compact way of getting what you want:

void Update() {
    bool open = (Time.time % 4) < 2;

    // ... (do stuff with open)