Execute code for a certain amount of time

Hey guys,

I was wondering, is it possible with javascript, to make it so that part of the code in your script will run for a couple of seconds, and then stop, but the rest of the script will run fine…

thanks

-Grady

Yes, use a coroutine. By “run for a couple of seconds”, what does that mean? Do something every frame?

function Whatever (runTime : float) {
	var timer = 0.0;
	while (timer < runTime) {
		// do something
		timer += Time.deltaTime;
		yield;
	}
}