Yielding for a changing amount of time?

I need to yield WaitForSeconds (amount) but that amount may change over time. Is there a way to yield for a dynamic “amount” instead of yielding for the original value?

Thanks in advance!

You could make a coroutine use a global time variable, then change that variable elsewhere if needed:

var waitTime : float;

function Wait (time : float) {
	waitTime = time;
	var t = 0.0;
	while (t < waitTime) {
		t += Time.deltaTime;
		yield;
	}
}

So that works like WaitForSeconds, except changing the waitTime variable will change the time it waits for, as long as the function is still running.

Your question example will damn near compile on its own. Where amount is a float variable and you change its value to whatever you need.

If you need only have the method fire after something else has occured then consider using an event to fire when the method needs to be called.