Copy link to clipboard
Copied
hi, I am pretty new to using after effects expressions and I am not quite sure how to solve my problem and i also found no working solution on the internet.
so I want to animate objects with always one in the background and one in the foreground and want to alternate them - this i figured out works with giving one layer:
rate = 1/1;
posterizeTime(rate);
seedRandom(index, false);
random(0,100) < 50 ? 0 : 100;
and the other one:
I am also working on a file with around 400 layers which also moves me to find a simple solution to my problem.
(I also wanted it to only randomize between second 1 and 6 but I am more frustrated about finding a solution to the timing problem)
thank you soo so much in advance!
Hi @Hani ElTiby ,
thank you very much for your help and quick response!
Unfortunatly I think I didn't quite understand your code so I wasn't able to make it work.
But I found another solution that seems to work with:
seedRandom(index, true);
minFrames = 100;
maxFrames = 200;
frameHold = Math.round(random(minFrames, maxFrames));
currentFrame = timeToFrames(time); // Aktuelles Frame der Komposition
switchTime = Math.floor(currentFrame / frameHold);
(switchTime % 2 == 0) ? 100 : 0;
and:
if (thisComp.laye
Copy link to clipboard
Copied
Hi @emma_7029,
Thanks for the question. Sorry you were not able to get n answer from an expert or team member. I did a little searching and found that if you add a couple more lines of code for the first data set, you may be able to randomize objects more easily. Try:
rate = 1/1; posterizeTime(rate); seedRandom(index, false); switchTime = random(1, 6); // Random time between 1 and 6 seconds timeToSwitch = Math.floor(time % switchTime) == 0; timeToSwitch ? 0 : 100;
I hope that helps. Let me know if it does.
Take Care,
Kevin
Copy link to clipboard
Copied
Hi @Kevin-Monahan ,
thank you so much for your quick reply and help!
Unfortunately this did not seem to be the solution. All the layers are still switching at 1s/2s/3s/...
I was just wondering whether it could be due to the rate that is set. Is there a way to randomize that?
Thank you so much and take care,
Emma
Copy link to clipboard
Copied
Hi Emma, Try this
Notice that the controller comes right after the randomized layers so it dynamicly count the layers above, by using it's own index in the random() function.
If you have layers above the randomized layers you may set the first random parameter manually or by pickwipping the first layer and get it's index
for example : rand = random(thisComp.layer("Medium Royal Blue Solid 2").index, index);
here are both expressions
the Controller layer first
posterizeTime(effect("Posterize")("Slider"));
rand = random(thisComp.layer("Medium Royal Blue Solid 2").index,index);
hide = Math.floor(rand);
then the opacity
hide = thisComp.layer("Controller").effect("Hide")("Slider");
if (hide == index) {value} else {0}
Copy link to clipboard
Copied
Hi @Hani ElTiby ,
thank you very much for your help and quick response!
Unfortunatly I think I didn't quite understand your code so I wasn't able to make it work.
But I found another solution that seems to work with:
seedRandom(index, true);
minFrames = 100;
maxFrames = 200;
frameHold = Math.round(random(minFrames, maxFrames));
currentFrame = timeToFrames(time); // Aktuelles Frame der Komposition
switchTime = Math.floor(currentFrame / frameHold);
(switchTime % 2 == 0) ? 100 : 0;
and:
if (thisComp.layer(index+1).transform.opacity == 0) 100;
else 0;
Thank you all very much for your help!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now