Pausing an Invoke for a time

I’m coding a game that’s 70% done, and now I’m doing the pause system. All loops and updates have an if(isPaused) to them, and works very nice.

However, in many places there is an Invoke(“Something”, delay), like on weapon cooldowns and unit respawning. But when I pause, I can’t use Time.timeScale = 0 because the pause menu animation depends on it.

Does anyone know a way to pause or delay an Invoke until the game is unpaused, without using the timeScale or reimplementing the Invoke system? I’m really running out of ideas here. :confused:

Late to the party, but here’s the after party stuff.

public void prepareForPlay()
{

	if (isPaused == false) {
		/*Game's meat*/
	}
	else 
	{
		StartCoroutine(asyncPrepareForPlay());
	}
}

IEnumerator asyncPrepareForPlay()
{
	yield return !isPaused;
	prepareForPlay ();
}

and this “prepareForPlay” function is called with Invoke(“prepareForPlay”,5.0f) somewhere, so when prepareforplay is called and game is paused(isPaused==true), it will go to coroutine and will not call that function until isPaused is FALSE.
I Hope it helps.

You could also set your animation to unscaled time in the inspector window under the animator component. Im late, however this could be for anyone who may be reading this in the future. :slight_smile: