Hello everyone !
I’m trying to make a texture blend to one another in 5 sec when I press space.
I have found a shader that works well on the forum everything goes the way I want but when I’m trying to update it in 5 sec with that code :
var timeLeft = 0.000;
var duration = 0.000;
function Start () {
}
function Update () {
if (Input.GetKeyDown("space")) {
// print("space key was pressed in Update");
while (duration <= 5) {
timeLeft += Time.deltaTime;
duration += Time.deltaTime;
// print(timeLeft);
// print(duration);
var lerp = Mathf.PingPong (timeLeft, duration) / duration;
GetComponent.<Renderer>().material.SetFloat( "_Blend", lerp );
}
}
else if (duration >= 5) {
duration = 0;
}
}
It just change my texture in one frame and I don’t know why, shouldn’t it be doing it in 5sec (as duration has +Time.deltaTime everyframe?).
Thanks in advance