Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Trigger Pre-Comped Animation through Condition

  • Dan Ebberts

    January 9, 2019 at 8:26 pm

    That changes things quite a bit, but it brings up a couple of questions: What happens when it gets to the end of the animation? What happens if the animation gets re-triggered (b becomes less than a again) while the animation is running?

    Dan

  • Michael Müller

    January 9, 2019 at 8:47 pm

    End of the animation > I thought that maybe you could reset the time value to zero again, once 20 Iterations of the loop (and 20 frames of the animation) passed.

    Re-triggered while the animation is running > in this case, I’m pretty sure that situation will never occur. If it would be just one extra line of code, I’d prefer to not interrupt any current animation. But as I said, it’s probably not necessary.

    Is it really complicated? This starts to begin looking like a contract. You have a tip jar, do you?

    Thanks,

    Michael

  • Dan Ebberts

    January 9, 2019 at 11:07 pm

    >Is it really complicated?

    Well, it changes the algorithm completely. Probably something more like this (it may not be exactly right, but it should be close):


    a = thisComp.layer("AA").transform.position;
    b = thisComp.layer("BB").transform.position;
    d = 20; // duration of animation in frames
    t = framesToTime(d);
    lookingForOn = b.valueAtTime(time-t)[0] >= a.valueAtTime(time-t)[0];
    if (lookingForOn){
    while (d > 0){
    d--;
    t = framesToTime(d);
    if (b.valueAtTime(time-t)[0] < a.valueAtTime(time-t)[0]){
    break;
    }
    }
    }else{
    while (d > 0){
    d--;
    t = framesToTime(d);
    if (b.valueAtTime(time-t)[0] >= a.valueAtTime(time-t)[0]){
    break;
    }
    }
    while (d > 0){
    d--;
    t = framesToTime(d);
    if (b.valueAtTime(time-t)[0] < a.valueAtTime(time-t)[0]){
    break;
    }
    }
    }
    t

    Dan

  • Michael Müller

    January 10, 2019 at 5:21 pm

    I’m glad it works now. In my attempt of understanding it, I was able to shorten it quite a bit, while maintaining functionality. This leads me to a question:

    I was able to completely get rid of the if statement. All I was left with, was the while statement that was included in both the “then” and the “else” of this if-statement. Did you include it to have the case of re-triggering covered? I couldn’t really wrap my head around it.

    The code now looks like this:


    a = thisComp.layer("Bubble L").transform.position;
    b = thisComp.layer("Trace").transform.position;
    d = 20; // duration of animation in frames
    t = framesToTime(d);
    while (d > 0){
    d--;
    t = framesToTime(d);
    if (b.valueAtTime(time-t)[0] < a.valueAtTime(time-t)[0]){
    break;
    }
    }
    t

    Thanks,

    Michael

Page 2 of 2

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