Hi I’m making a door open and close using a transform instead of animation
var speedTime : float;[1]
private var t: float = 0;
function Close() {
stateOpen = false;
stateClosing = true; // so we know its closing
while (t < speedTime) {
t += Time.deltaTime / speedTime; // sweeps from 0 to 1 in time seconds
transform.position = Vector3.Lerp(initialEnd, initialStart, t); // set position proportional to t
yield; // leave the routine and return here in the next frame
}
t = 0;
stateClosing = false; // so we know its not closing
stateClosed = true; // so we now its closed
}
after closing the door i have to wait a prolonged ammount of time before i can open it again only if speedTime is over 1.
it seems as if the while coroutine is waiting the length of speedTime until allowing itself to play again.
any help would be great I’m really stumped