I’ve been looking around for quite a while for this topic, and I know it’s almost overdone but still I cannot find an answer that solves my problem.
I am working on a small project that is supposed to be a match3 hybrid game and I’m trying to make the game stop for a couple of secods after a player has made a match so I can play an animation on the player’s character and have the enemy character play his own animation before the player moves again. The code I have needs to use the Update() so it can constantly check for matches as well as move the “gems” the player has selected. (I know that my code is not the best and that this could probably be done in much more efficient ways, but I’m really pressed by time and I need to make it work ASAP. I’ll work on refining it after I get a “playable alpha”, so to speak).
I came to realize that the problem why my game wouldn’t stop was the Update function. So I went on and created a CoUpdate() since I read that this should solve the issue, but it didn’t and I really don’t know what else to do. So, I turn to you guys… I can’t take any more for today so I’m hoping that I’ll get a hint until I get back to work on that. Here’s a pseudocode of how things work right now:
//do start stuff
private IEnumerator CoUpdate()
//check stuff and do things every frame
yield return null;
public void aFunction()
//triggered by the player, called from another script
//turns triggers on that activate the things that happen in CoUpdate
//needs to make the game wait after is done
IEnumerator WaitForAnimation ( )
//triggers the animation from the player's animator script
//should make the game wait until the animation is over
yield return new WaitForSeconds(3);
Thank you for your time.