Copy link to clipboard
Copied
var x = 0;
var y = 2;
var z = 10;
I want var x value to be increased by 1 (x + 1) after every var y seconds untill time is equal to var z.
What to do?
Dan's idea to use floor to increase by 1 is very elegant. But I think your condition with the z must be implemented like this (since z should be a limit on the time, not on the final value, if I understand it correctly):
x = Math.floor(Math.min(time,z)/y);
Copy link to clipboard
Copied
Expressions don't have memory, so variables don't survive from one frame to the next, but you can calulate your x value based on the current time, like this:
var x = 0;
var y = 2;
var z = 10;
x += Math.floor(time/y);
x = Math.min(x,z);
or elapsed time since the layer's in point, like this:
var x = 0;
var y = 2;
var z = 10;
x += Math.floor((time-inPoint)/y);
x = Math.min(x,z);
Copy link to clipboard
Copied
Dan's idea to use floor to increase by 1 is very elegant. But I think your condition with the z must be implemented like this (since z should be a limit on the time, not on the final value, if I understand it correctly):
x = Math.floor(Math.min(time,z)/y);
Find more inspiration, events, and resources on the new Adobe Community
Explore Now