This script is suppose to make a loop of a cube moving back and forth.
var end : float = 4.0;
var Move : int = 8;
function Update () {
if(end <= 4)
{
Move = 8;
transform.Translate(0, 0, Move * Time.deltaTime);
end -= Time.deltaTime;
if(end <= 0)
{
end += Time.deltaTime;
Move = -16;
transform.Translate(0, 0, Move * Time.deltaTime);
}
}
}
But the timer doesn’t go back up. It doesn’t stay at zero either, which is weird. the variable Move is set equal to -16 and then the variable end locks in place around 0.005373292, but doesn’t rise back up to 4 to continue the loop. The cube then infinitely goes backwards. Is their a specific way to make Time.deltaTime go up once its already going down?