Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Property launch animation

  • Property launch animation

    Posted by Melissa Franch on October 26, 2022 at 7:54 am

    Hello!

    I have a bar that is animated, for example with a wiggle, and every time the X scale reaches 100 it launches the animation of another layer.

    The layer that has the animation is a precomp that has timeremap enabled, and the timeremap is where I think I have to put the expression.

    I’m trying with If but I don’t know how to launch the animation.

    Filip Vandueren replied 3 years, 9 months ago 2 Members · 5 Replies
  • 5 Replies
  • Filip Vandueren

    October 26, 2022 at 9:44 am

    Hi Melissa,

    something like this (expression for timeRemapping)

    prop = thisComp.layer("0").effect("Slider Control")("Slider");
    trigger = false;
    for (t=time; t>=0; t-=thisComp.frameDuration) {
    if (prop.valueAtTime(t) >= 100 ) {
    trigger = true;
    } else if (trigger == true ) {
    break;
    }
    }
    if (t<=0) {
    0;
    } else {
    valueAtTime(time-t);
    }

    I’m assuming the first frame is empty, animation starts at 2nd frame of precomp.

  • Filip Vandueren

    October 26, 2022 at 9:53 am

    In your case the first line can be something like:

    prop = thisComp.layer("Shape Layer 1").transform.scale;

    and the check needs to be against [0] (the X-component) of the 2D scale:

    if (prop.valueAtTime(t)[0]>= 100 ) {
  • Melissa Franch

    October 26, 2022 at 11:18 am

    It works perfect! Thank you very much!

    Could you explain it to me? It’s still hard for me to understand the “for” and I don’t understand the variable that you define trigger.

  • Filip Vandueren

    October 26, 2022 at 1:57 pm

    I’ll try to explain:

    The for loop starts at the current time, and steps back in time 1 frameDuration per loop until we are at time 0 (the beginning of the comp)

    At each time/frame we inspect the value of the property (valueAtTime).

    If it is more than 100, that’s the condition to start out animation.

    But if we would keep it at this, then the animation would only trigger at the last frame that’s >=100 (because we are looking backwards) we actually want to start our animation at the first frame where it was 100, not the last (for a run of consecutive frames that satisfy the condition).

    So I remember that we’ve encountered a frame that was more than 100 by setting trigger to true, but the loop continues to the previous frame to inspect that value.

    If we encounter a frame where the value is less than 100, the loop should also continue. Unless trigger is true, because that means we have now reached the end of consecutive frames that were triggering. We break out of the loop and the variable t now holds the time-value of 1 frame before our animation should trigger.

    Triggering the animation in this case is then archived by looking at the value timeremapping had “t seconds ago”. Presumably the timeremapping has its default keyframes at the start of the layer that would playback the animation.

    If t is 0 or less than 0, this means the loop where we we’re looking for values that were more than 100 was able to loop all the way through without finding a trigger. So we should return 0, so the timeremapping is frozen.

    I hope this explanation didn’t over complicate matters. I’m not the best at breaking down code to English 🙂

  • Filip Vandueren

    October 27, 2022 at 10:14 am

    Oh yeah,

    if (t<=0) {

    should better be:

    if (trigger==false) {

    Because if a trigger would occur at exactly the first frame of the comp, the code as it is now would miss it, and anyway trigger being false is the more logical condition that, well, a trigger didn’t happen (duh) 😉

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