Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Triggering linear animation / time-remapping with markers

  • Triggering linear animation / time-remapping with markers

    Posted by Malte Hillebrand on October 11, 2019 at 7:23 am

    Hello everybody,

    I’m trying to trigger an animation within a precomp with markers on the precomp layer. Inside the precomp I’ve put composition markers whenever a new part of the animation starts. It is based off of Dan Ebbert’s marker animation script.

    The main difference is: I’m trying to have the time gradually increase from the one precomp marker’s time to the next. Also I want it to loop through the precomp’s markers/animation for as long as there are markers on the precomp layer.

    I’m really not sure why it’s not working, but I’m just starting to learn more about AE Scripting so I’m hoping anybody can tell me whats wrong with my expression.

    This is the expression on the Time-Remap of the precomp layer.

    preComp = comp(name);

    var previousMarker;
    nextMarkerPrecomp = 0;

    if(marker.nearestKey(time).time <= time){
    previousMarker = marker.nearestKey(time).index;
    }

    else{
    previousMarker = marker.nearestKey(time).index -1;
    }

    if(previousMarker > marker.numKeys) {
    if(time >= marker.key(previousMarker).time && time < marker.key(previousMarker+1).time){
    if (nextMarkerPrecomp == preComp.marker.numKeys - 1) { // If next Precomp Marker is the last, reset the PreCompMarker index
    nextMarkerPrecomp = 0;
    }
    else {
    nextMarkerPrecomp = (marker.nearestKey(time).index % preComp.marker.numKeys) - 1;
    }
    linear(time, marker.key(previousMarker).time, marker.key(previousMarker+1).time, preComp.marker.key(nextMarkerPrecomp-1).time, preComp.marker.key(nextMarkerPrecomp).time);
    }
    }

    Edit: To be more precise: What’s happening now is that at every marker on my precomp layer the time remapping function increases by one second without any interpolation between the markers

    Malte Hillebrand replied 6 years, 7 months ago 1 Member · 3 Replies
  • 3 Replies
  • Malte Hillebrand

    October 18, 2019 at 6:55 pm

    bump … nobody with any idea ?

  • Malte Hillebrand

    October 24, 2019 at 4:54 pm

    So if anyone is interested, this is what I have right now:

    The time-remapping works for one cycle of the markers in the precomp, then starts the loop again and repeats the first linear time-remapping again. I think the problem is the nextMarkerPrecomp = 2. Because After Effects’ expressions are weird to me as the keyframe index seems to start at 1 (?) and there is no console to easily check values, I’m not sure where to tackle the problem.

    preComp = comp(name);

    var previousMarker;
    var nextMarkerPrecomp; // 2 weil scheinbar Marker Index 1 == erster Marker ist, NICHT 0

    if(marker.nearestKey(time).time <= time){
    previousMarker = marker.nearestKey(time).index;
    }

    else{
    previousMarker = marker.nearestKey(time).index -1;
    }

    if(previousMarker < marker.numKeys) {
    if(time >= marker.key(previousMarker).time && time < marker.key(previousMarker+1).time){
    if (previousMarker % preComp.marker.numKeys != 0) { // If next Precomp Marker is NOT the first
    nextMarkerPrecomp = (previousMarker % preComp.marker.numKeys) + 1;
    }
    else { // Else reset the PreCompMarker index ! probably error here
    nextMarkerPrecomp = 2;
    }
    // Then linear Timing between the current and next marker
    linear(time, marker.key(previousMarker).time, marker.key(previousMarker+1).time, preComp.marker.key(nextMarkerPrecomp-1).time, preComp.marker.key(nextMarkerPrecomp).time);
    }
    }

  • Malte Hillebrand

    October 25, 2019 at 8:37 pm

    just in case somebody gets here via google, this is the final expression:


    precompMarker = comp(name).marker;

    var compMarker;
    var triggerMarker;

    if(marker.nearestKey(time).time <= time){
    compMarker= marker.nearestKey(time).index;
    }

    else{
    compMarker= marker.nearestKey(time).index -1;
    }

    if(compMarker< marker.numKeys) { // If the current marker is NOT the last, continue
    if(compMarker< precompMarker.numKeys) { // If still in the first loop
    triggerMarker= compMarker% precompMarker.numKeys;
    }
    if(compMarker>= precompMarker.numKeys) { // If entering / in any loop after the first
    triggerMarker= compMarker% (precompMarker.numKeys - 1);
    if(triggerMarker== 0) { // If the triggerMarker is 0 we have to assign it one before the last one of triggerMarker so we have a compplete loop
    triggerMarker= precompMarker.numKeys - 1;
    }
    }
    linear(time, marker.key(compMarker).time, marker.key(compMarker+1).time, precompMarker.key(triggerMarker).time, precompMarker.key(triggerMarker+1).time);
    }

    sorry for bothering you as a noob, I won’t post in your precious board again

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