-
If, Then, Stop Until… or something like that
Hello!
I’ve tried for hours searching so many things, but have come up with nothing. What I’m trying to do is select a random number *one time* when a condition is true, then only generate a new number after the condition is false, then *newly* true again.
So I’ve got this on the Rotation parameter of a layer:
seedRandom(0,true);
boom = effect(“Boom”)(“Slider”);
if(boom > 3){seedRandom(boom,true)};//If boom slider is greater than 3, pick a random number.
pick4 = Math.round(random(3));//Generate random integer between 0 and 3.
if(pick4 == 0){0}else if(pick4 == 1){90}else if(pick4 == 2){180}else if(pick4 == 3){270};//Rotate to 0,90,180, or 270, depending on the random number.So I want one of 4 rotation options (0,90,180, or 270) to be randomly selected when my slider goes above 3, but I don’t want new rotations every frame while the slider is over 3 (which it currently does). I want it to hold the rotation until not only the slider dips down to *less than 3* (lol <3) but also until it goes over 3 again, THEN pick a new rotation and hold it, etc. So like a gun, one shell comes out when you cock it back, then it has to go both forward and back again before you get a new shell.
I don’t know if it’s a matter of using a variable to save the state until (boom < 3) again, or if it’s somehow “holding” things until < 3…. I even tried posterizing time to freeze things, but it doesn’t quite work right, and is clearly just a hack.
Any ideas? Thanks for any feedback.
seedRandom(0,true);
boom = effect("Boom")("Slider");
if(boom > 3){seedRandom(boom,true)};//If boom slider is greater than 3, pick a random number.
pick4 = Math.round(random(3));//Generate random integer between 0 and 3.
if(pick4 == 0){0}else if(pick4 == 1){90}else if(pick4 == 2){180}else if(pick4 == 3){270};//Rotate to 0,90,180, or 270, depending on the random number.



