Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions valueAtTime for multiple markers

  • valueAtTime for multiple markers

    Posted by Jean Livenais on August 25, 2023 at 11:05 am

    Hello,

    I would like to trigger an animation multiple times for 3 layers with 3 markers.

    The main animation is on the Layer “LEAD ANIMATION” and lasts 1 second.

    I have 3 layers which are named A, B and C. I want to animate their opacity multiple times with the “LEAD ANIMATION” model.

    And on the layer “MARKER”, there are the three markers A, B and C that repeat randomly.

    I arranged this expression that allows to trigger the animation multiple times for each layer:

    m = thisComp.layer(“MARKER”).marker;

    animation= thisComp.layer(“LEAD ANIMATION”).transform.opacity;

    tag = thisLayer.name;

    nk = m.nearestKey(time);

    pki = nk.index – (nk.time > time && nk.index>1 ? 1: 0);

    k = m.key(pki);

    if (k.comment==tag) {

    animation.valueAtTime(time-k.time);

    } else {

    animation.valueAtTime(0);

    }

    The animation starts well but it stops when the next marker is reached.

    I am not sure how to correct this expression to make the animation ends well even if the next marker is reached before the end of the animation.

    Can you help me please?

    Brie Clayton replied 2 years, 11 months ago 3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    August 25, 2023 at 1:18 pm

    Try it this way:

    m = thisComp.layer("MARKER").marker;
    animation= thisComp.layer("LEAD ANIMATION").transform.opacity;
    tag = thisLayer.name;
    t = 0;
    if (m.numKeys > 0){
    nk = m.nearestKey(time).index;
    if (time < m.key(nk).time) nk--;
    while (nk > 0){
    if (m.key(nk).comment == tag) break;
    nk--;
    }
    t = nk > 0 ? time - m.key(nk).time : 0;
    }
    animation.valueAtTime(t)
  • Jean Livenais

    August 25, 2023 at 5:24 pm

    Excellent Dan !

    It works like a charm!

    Thank you very much!

  • Brie Clayton

    August 25, 2023 at 10:04 pm

    Thanks for the solve, Dan!

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