Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Markers to control position In

  • Markers to control position In

    Posted by Nathaniel Logan on January 25, 2019 at 4:11 am

    Hi,

    I was wondering is it possible to trigger layer position animation from a marker.

    So the position keyframes are already set but the animation should start only when the marker begins on the same layer.

    Can anyone help me on this expression.

    Much appreciated.
    Thanks

    Nathaniel Logan replied 7 years, 6 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    January 25, 2019 at 5:33 am

    Something like this probably:


    m = marker;
    n = 0;
    if (m.numKeys > 0){
    n = m.nearestKey(time).index;
    if (m.key(n).time > time) n--;
    }
    t = n > 0 ? time - m.key(n).time : 0;
    valueAtTime(key(1).time + t)

    Dan

  • Nathaniel Logan

    January 25, 2019 at 11:47 am

    Hi Dan the above snippet works like Charm thank you so much ☺

    Also went through one of your script that triggers the Animation In/Out whichever the 3rd Keyframe is…

    outKey = 3;
    if (time > key(outKey-1).time){
    m = marker;
    n = 0;
    if (m.numKeys > 0){
    n = m.nearestKey(time).index;
    if (m.key(n).time > time) n–;
    }
    t = n > 0 ? time – m.key(n).time : 0;
    valueAtTime(key(outKey).time + t);
    }else{
    value;
    }

    But is it possible to add two markers for a layer and keyframe the Position and Connect the first two keyframes to “In” Marker and next Two keyframes to “Out” Marker.

    Much appreciated.
    Thanks 🙂

  • Dan Ebberts

    January 25, 2019 at 5:01 pm

    Something like this maybe:


    m = marker;
    n = 0;
    if (m.numKeys > 0){
    n = m.nearestKey(time).index;
    if (m.key(n).time > time) n--;
    }
    if (n == 0){
    t = key(1).time;
    }else if (n == 1){
    t = key(1).time + Math.min(time - m.key(1).time,key(2).time-key(1).time);
    }else{
    t = key(3).time + (time - m.key(2).time);
    }
    valueAtTime(t)

    Dan

  • Nathaniel Logan

    January 25, 2019 at 5:38 pm

    Wonderful Dan, this script works like Charm, you’re the best of the best.

    Thank you so much, ☺ ☺ ☺

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