Trouble with simple Coroutine

Hi all,

The following script is using a coroutine to pause for 2 seconds
and then do GameObject.FindWithTag. Doesn’t appear to be working, any thoughts?
Thanks,
Greg

using UnityEngine;
using System.Collections;

public class DisableScript : MonoBehaviour {


 IEnumerator wait()
 {
    //Do whatever you need done here before waiting

    yield return new WaitForSeconds (2f);

    //do stuff after the 2 seconds

 }

 void Update()



 {


 StartCoroutine("wait");




 GameObject varGameObject = GameObject.FindWithTag("MainCamera"); 





 varGameObject.GetComponent<CameraShake>().enabled = false;


 }}

You have to do the find IN the coroutine. Calling StartCoroutine doesn’t block the code that called it.

using UnityEngine;
using System.Collections;

public class DisableScript : MonoBehaviour
{

    void Start()
    {
        this.StartCoroutine(this.WaitAndDisable());
    }
   
    IEnumerator WaitAndDisable()
    {
        yield return new WaitForSeconds(2f);
       
        GameObject go = GameObject.FindWithTag("MainCamera");
        go.GetComponent<CameraShake>().enabled = false;
    }

}

Awesome, thanks lordofduct!
Makes sense to me now that I see it.
I appreciate your time and help!