-
Increase variable each frame, check if it’s too big and reset it, then keep increasing
Hey all,
So I’m pretty new to AE, and very new to expressions, but I do have some experience with entry level coding. I have a layer that is tiled, and I want it to scroll downward with increasing speed. Accomplishing that is pretty easy, I just used this expression:temp = transform.position[1];
spd = effect(“Slider Control”)(“Slider”);
temp = (time*spd);
[960, temp]Then I keyframed the slider to increase over time. However, the problem arises when I run out of tiles. I could just increase the number of tiles to something enormous, but because I’m speeding up more and more over time, I don’t think that’s the best solution. I decided to make an if statement that would reset the position to 0 once I reached the end of my tile.
I tried this:temp = transform.position[1];
spd = effect(“Slider Control”)(“Slider”);
temp = (time*spd);
if (temp > 12960) temp = 0;
[960, temp]But unfortunately when it hits the if statement, it resets the position then stops increasing temp each frame. SO what I need is a loop that will increase temp, the reset the position if it’s too big. My last attempt was this:
temp = transform.position[1];
spd = effect(“Slider Control”)(“Slider”);
for (i=0; i 12960) temp = 0;
}
[960, temp]But that does the exact same thing as the second one AFAIK. Thanks, any help would be appreciated.
temp = transform.position[1];
spd = effect("Slider Control")("Slider");
for (i=0; i 12960) temp = 0;
}
[960, temp]