Using Invoke from within a static function issue

When using invoke function from within a static function it throws this error: error CS0120: An object reference is required to access non-static member `UnityEngine.MonoBehaviour.Invoke(string, float)'.

static void doSomthing()
{
       .
       .
       invoke("doAnotherThing", 0.5f);
}

What should I do? I need half a second delay.

StartCoroutine() also throws the same error.

Does it have to be a static function? I don’t think you can get that to work with static functions, since Invoke inherently requires an instance; it couldn’t be static.

–Eric

You need a Monobehavior to do anything time-related, I believe. However, if you use a Coroutine, it doesn’t actually have to be a method of the Monobehavior, so you could potentially create a temporary object for the purpose.