Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Trigger “position” with markers

  • Trigger “position” with markers

    Posted by Henri Yates on October 25, 2021 at 10:31 am

    Hello, I want to animate “position” of an item. I want that the marker’s comment (which will be a number) to add or subtract from the previous keyframe value and place and new keyframe under the marker.

    For example; the first keyframe (marker, Y Position) is 50, which I initially set. I want the second keyframe value to be the second marker’s comment plus the previous keyframe’s second value (Y Position) which is 50 so the second keyframe will be 5 0+ 150 = 200. And the third keyframe will be 200 + 30 = 230 etc.

    Any help?

    Thanks

    Meng Zhiqun replied 4 years, 6 months ago 2 Members · 1 Reply
  • 1 Reply
  • Meng Zhiqun

    October 30, 2021 at 7:34 am

    You can try this. Put this expression in the position. 🙂

    var aniTime = 10/30;// Change this to change the timing it takes to go up/down.

    n = 0;

    if (marker.numKeys > 0) {

    n = marker.nearestKey(time).index;

    if (marker.key(n).time > time) {

    n--;

    }

    }

    if (n == 0) {

    var y = value[1];

    }else{

    var y = value[1] + linear(time, marker.key(n).time, marker.key(n).time+ aniTime, newY().split(",")[0] , newY().split(",")[1] );

    }

    function newY(){

    var curYVal = 0;

    var newYVal = 0;

    var target = thisLayer;

    var tNumKeys = target.marker.numKeys;

    if (tNumKeys > 0) {

    for (var i=1;i<=tNumKeys;i++){

    var curKey = target.marker.key(i);

    if (curKey.time <= time) {

    newYVal+= Number(curKey.comment);

    try{

    curYVal+= Number(target.marker.key(i-1).comment);

    }catch(e){

    curYVal = 0;

    }

    }

    }

    }

    return curYVal + "," + newYVal;

    }

    var x = value[0];

    [x,y];

    Hope this helps!

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