Yield Misery

I am trying to perform a sequence of functions but I want each to start AFTER the previous one has finished… I have som thing like…

hintOverlayScript.ActivateHintOverlay(4,1);
hintOverlayScript.ActivateHintOverlay(4,1);
hintOverlayScript.ActivateHintOverlay(4,1);
hintOverlayScript.ActivateHintOverlay(8,1);

The problem is as soon as the code runs only the last function output is visible as there is obviously no yield statement anywhere.
Now, I have tried with Coroutines and Yields in various combinations but absolutly none of it is working for me…Whats the easiest way to chain a sequence of functions??
Ta

BTW also when I do…
yield StartCoroutine("hintOverlayScript.ActivateHintOverlay(4,1)"); I get a cannot start coroutine error…why?

Have one function call the next one.

Right now you have all four calls in the same function. Have function 1, when it’s done, call function 2. When function 2 is done, have it call function 3. This will ensure that function 2 doesn’t start until 1 is complete.

I could do. The problem is that this series of texts is kind of an intro and I use the same function to bring up hint boxes individually later in the game.

As soon as I start putting in things like if(intro) it start to mess up the function…I guess what I’m sayigh is that is a messy way to do it and I’d like to be a bit tidier.

Although I may resort to the ‘bish,bash,bosh method’ soon :wink:

okay this did it…

hintOverlayScript.ActivateHintOverlay(1,3);
	while(hintOverlayScript.running==true)
	{
		yield;
	}
hintOverlayScript.ActivateHintOverlay(1,8);

Basically I stuck a running variable into the script and while this is true I yield. This seems to work…for now at least…

Cheers

Assuming that ActivateHintOverlay has yield statements in it (and assuming you use JS), this should do the trick:

yield StartCoroutine(hintOverlayScript.ActivateHintOverlay(4,1));
yield StartCoroutine(hintOverlayScript.ActivateHintOverlay(4,1));
yield StartCoroutine(hintOverlayScript.ActivateHintOverlay(4,1));
yield StartCoroutine(hintOverlayScript.ActivateHintOverlay(8,1));