ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

How to modify opacity within a loop with variable speed

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Erich Geiersberger
How to modify opacity within a loop with variable speed
on May 2, 2019 at 11:21:24 pm

Hello everybody,

I am looking for a possibility to modify the opacity of some objects within a loop.
This is part of a lung animation. Breathing is a looped comp and can be speed up or slowed down over time by a slider in a null layer of the master comp.

The loops time remap is controlled by Dan Ebberts script:

spd = thisComp.layer("settings").effect("AnimationSpeed")("Schieberegler");
n = spd.numKeys;
if (n > 0 && spd.key(1).time < time){
accum = spd.key(1).value*(spd.key(1).time - inPoint);
for (i = 2; i <= n; i++){
if (spd.key(i).time > time) break;
k1 = spd.key(i-1);
k2 = spd.key(i);
accum += (k1.value + k2.value)*(k2.time - k1.time)/2;
accum += (spd.value + spd.key(i-1).value)*(time - spd.key(i-1).time)/2;
accum = spd.value*(time - inPoint);

if (numKeys > 1){
d = key(numKeys).time - key(1).time;
t = (accum - key(1).time)%d;
valueAtTime (key(1).time + t);

I would now want to fade some objects inside the loop in and out over time, also controlled by a keyframed slider in the master comp. I have searched through the archives for hours but can't seem to find a way to get it working. But maybe I'm already brain dead by now.
Any help appreciated.


Return to posts index

Filip Vandueren
Re: How to modify opacity within a loop with variable speed
on May 6, 2019 at 8:10:25 am

It cannot be done.
The precomp can indeed reference a slider in a different comp, but it would get that slider's value "at the current time".
The current time in that precomp would never exceed its own length (for example 2 seconds), so it would respond to the first two seconds of your sliders value/keyframes, but it would also loop that…

A workaround would be to not use time-remapping, but use Dan's expression on a second slider called "myTime".

Make sure your precomp and all of its layers are long enough (as long as the masterComp), and for every keyframed property (so, not opacity) add this expression:
-> basically point this to the slider

This will loop all their keyframes, same effect as the timeremapping, but with more flexibility.

The layers whose opacity need to be controlled by sliders should just be pick-whipped to your slider for an expressio something like:

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 All Rights Reserved