Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random fade in/out of multiple layers so only one layer is visible at a time

  • Random fade in/out of multiple layers so only one layer is visible at a time

    Posted by Al Mach on October 13, 2021 at 8:45 pm

    I have 27 layers that I want to randomly appear (quick fade on then fade off), but not overlap so that if one is at full opacity the others are invisible. Is this possible?

    Al Mach replied 4 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    October 13, 2021 at 9:20 pm

    Just as a quick demo, create a null named “Control” with a Slider Control and keep this layer at the bottom of your layer stack (below your 27 layers). Add this expression to the slider:

    n = 27;

    period = 1;

    seg = Math.floor(time/period);

    seedRandom(seg,true);

    Math.floor(random(n)) + 1;

    This will broadcast an integer between 1 and 27 for the other layers to use to decide whether to fade up or not. Apply this opacity expression to your 27 layers:

    period = 1;

    fadeTime = .25;

    t = time%period;

    targetLayer = thisComp.layer("Control").effect("Slider Control")("Slider");

    if (targetLayer == index){

    if (t < fadeTime)

    ease(t,0,fadeTime,0,100)

    else

    ease(t,fadeTime,fadeTime*2,100,0);

    }else

    0

    Adjust the period and fadeTime (fadeTime should be half the period, or less).

  • Al Mach

    October 13, 2021 at 9:43 pm

    Thank you, it worked perfectly.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy