Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Fade back out when equal to a value..

  • Fade back out when equal to a value..

    Posted by John Gardner on April 1, 2021 at 5:13 pm

    Hi everyone,

    I have a layer fading in based on the distance to the camera. So the layer goes from 0 to 30% opacity based on the camera distance. But after the layer hits a 30% opacity threshold, I then want the layer to automatically fade back out after X amount of time.

    Here is the current expression, which will fade in the layer up to 30%

    start = thisComp.layer(“Control”).effect(“FadeStart”)(“Slider”);
    end = thisComp.layer(“Control”).effect(“FadeEnd”)(“Slider”);
    C = thisComp.layer(“HandyCam_Camera”);
    CameraPos = C.toWorld([0,0,0]);
    LayerPos = toWorld(anchorPoint);
    Difference = length(CameraPos, LayerPos);
    ease(Difference, start, end, effect(“Gradation End”)(“Slider”), effect(“Gradation Start”)(“Slider”))

    I just don’t know how to have it automatically fade back out after X amount of time.

    Any suggestions?

    Thanks,

    John

    John Gardner replied 5 years, 1 month ago 2 Members · 3 Replies
  • 3 Replies
  • John Gardner

    April 1, 2021 at 5:28 pm

    In case it helps, I cleaned up the expression so its not referencing sliders..

    start = 2000;
    end = 700;
    C = thisComp.layer(“HandyCam_Camera”);
    CameraPos = C.toWorld([0,0,0]);
    LayerPos = toWorld(anchorPoint);
    Difference = length(CameraPos, LayerPos);
    ease(Difference, start, end, 30, 0)

  • Dan Ebberts

    April 2, 2021 at 5:07 pm

    It’s tricky, and can be complicated by exactly how you need it to operate. In any case, the trick is to find the event that triggers the fade. In the simplest scenario (where once the layer reaches the end threshold, it stays there) you just need to check if the Difference is currently less than end. If so, you need to use valueAtTime() to traverse back in time, frame by frame, to find out when that happened (Difference went from greater than end to less than end) and use that time to drive your fade out. If your scenario is more complex (like there might be multiple triggering events) the expression gets correspondingly more complicated.

  • John Gardner

    April 2, 2021 at 5:16 pm

    Thanks for replying!

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