-
If statement doesn’t work in expression
I’m trying to make clouds move out of frame and than appear again from the other side.
First time if statement works as expected. tBound becomes 40s and it offsets cloud. But when time gets bigger than 40 nothing happens. Neither offset variable gets bigger nor tBound. If statement doesn’t work anymore. What’s the problem here?
var vel = 100;
var pInit = position.valueAtTime(0)[0]; // initial position of a cloud
var tInit = (thisComp.width-pInit)/vel; // time it takes to cross the right border starting from init position
var tFull = (thisComp.width+width)/vel; // time it takes to cross the frame starting behind the left border
var offset = 0;
tBound = tInit;if(time > tBound) {
tBound += tFull;
offset += thisComp.width+width;
}[value[0]+time*vel-offset,value[1]]