Coroutine not running after yield return new WaitForSeconds

I have a coroutine that is used to move objects.

IEnumerator Move(float start, float end, float length, float delay)
    	{
    		yield return new WaitForSeconds(delay);
    
    			for (float i = 0; i < 1; i += 0.01667f*(1/length))
    			{
    				MoveEndTapeTex =  Mathf.Lerp(start, end, i);
    				yield return null;
    			}
    			MoveEndTapeTex = end; 
    	}

The problem was that the coroutine never passes the yield return new WaitForSeconds(delay); if the delay is greater 0. Does anyone know what the problem is and how to fix it?

smallbit has the solution in my case. One developer started using timescale=0 when a game is paused. We were using a coroutine to handle fading up a loading screen and it was never getting past the first yield and this was why. When Time.timescale=0 WaitforFixedUpdates don’t happen and waitforseconds never returns. Just setting timescale to 1 at the start of the function fixed the issues.

This won’t be a very intelligent answer, but if I remember correctly, for loops in IEnumerators are HIGHLY advised against for performance and stability reasons. Also, have you tried putting a Debug.Log(“Test”); after the yield to see if anything is called afterwards? It’s possible the following code just doesn’t function like you’d like it to.

in my case it wasn’t the timescale or the object being destroyed… (its my game manager so its live during all the game) but i forgot that i used StopAllCoroutines(); around my code and it was killing this particular coroutine with other routines that actually needed to be killed… so now i need to figure out how to let this particular coroutine alive and kill the others.

check if you have a StopAllCoroutines(); around your code.