Lerping between 2 values over "X" seconds - outside of Update function

Hey there,

I’m trying to lerp between 2 values over a specific time (using mathf.lerp and time.deltatime) - traditionally I’ve always done this in an Update function, but due to the nature of what I’m trying to do in this case, it has to be in it’s own Function

Does anyone have any ideas? To make things more simple, I want to display text on a gui.button counting down from 5 to 0 (over 5 seconds) - but this number is going to change - it may need to countdown from 3 to 0 over 3 seconds etc

bump anyone have any ideas? I’m totally stumped and can’t seem to get anything to work

Bumping a topic in less than an hour is really not necessary. Anyway, I don’t see any need for Lerp here.

private var timer = 0.0;

function Countdown (startTime : float) {
	timer = startTime;
	while (timer > 0.0) {
		timer -= Time.deltaTime;		
		yield;
	}
}

–Eric

Works perfectly, thanks so much man, I wasn’t familiar with the “while” statement, still learning!