-
Convert increasing variable to looping variable
I’m trying to write an expression that converts a constantly increasing variable, like time, to a looping variable. Kind of like the ‘linear’ function but instead of clamping the value translation to either end of the range, it would loop the variable back around to the beginning again. I’ve written this looping expression, but it doesn’t really allow me to set the range of output values, it just cycles the variable every 10 seconds from 0 to 10. I also feel like there’s a better way to do this that I am not aware of.
t = time;
t = time;
v = t;
i = 0;
End = 10
if (t>End){
i = Math.floor(t/End);
v = t - (i*End);
}[v];