Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Triggering specific keyframes animations with marker comment

  • Triggering specific keyframes animations with marker comment

    Posted by Daniel Futerman on November 12, 2015 at 7:26 am

    Hi all,

    I’m trying to trigger multiple keyframes animations once reaching an “OutPoint” marker.

    So essentially, the layer marker should trigger the animation between keyframes 2 & 3. I’m doing this to give the user a simple way to adjust the out animation instead of manually re-adjusting keyfrmaes.

    What I’d like to happen is if the user stretches the marker further in time, the animation between keyframes 1 & 2 would be slower, and once the time hits the marker “OutPoint” keframes 2 & 3 will come into action (the parameters between 2 & 3 never change).

    It would be great if the same expression could be copy-pasted to the mask, position, scale, z rotation and opacity properties:

    I’ve tried multiple expressions by Dan Ebbert but couldn’t get it to work as I need.

    Really appreciate your help!

    After Effects Template & Photoshop Tutorials:
    https://www.amigo-productions.com

    Daniel Futerman replied 10 years, 5 months ago 3 Members · 16 Replies
  • 16 Replies
  • Miguel De mendoza

    November 12, 2015 at 11:04 am

    Look at this post: https://forums.creativecow.net/thread/227/30494

    You can tweek it to change any property of any layer. Here is an example on how I use this tecchnique:

    As you can see on top, there are various ‘master’ comps named “triangles_n”. You only need to set the triangles(or any layer) position where do you want on each ‘master’ comp and then control the animations by the marker comment.

  • Daniel Futerman

    November 12, 2015 at 11:46 am

    Thanks for your reply Miguel, looks very interesting but to be honest, modifying that code would be beyond my level of knowledge in expressions.

    What changes would you make to apply it to my scenario? Or is there a simpler expression I could use instead?

    Thanks a lot!

    After Effects Template & Photoshop Tutorials:
    https://www.amigo-productions.com

  • Daniel Futerman

    November 13, 2015 at 6:34 am

    Anyone else? 🙂

    The only thing I have so far is the following, but it only the entire keyframe animation to start once reaching the marker, rather than having keyframe 2 start when reaching the marker.

    (I found this expression on reddit)

    // Keyframe your animation, starting on frame 0
    // This property will animate at every marker on this layer

    // If the property has no keyframes, the value at frame 0 is output
    if (thisProperty.numKeys == 0) { t = 0; }

    // Find the previous marker from current time
    else {
    n = 0;
    if (marker.numKeys > 0){
    n = marker.nearestKey(time).index;
    if (marker.key(n).time > time){ n--;}
    }

    // If there is no previous marker, the value at frame 0 is output
    if (n == 0){ t = 0; }

    // Calculate t from elapsed time since the last keyframe
    else{
    m = marker.key(n);
    t = time - m.time;
    }
    }
    valueAtTime(t)

    After Effects Template & Photoshop Tutorials:
    https://www.amigo-productions.com

  • Dan Ebberts

    November 13, 2015 at 7:48 am

    I think it would be like this:


    tm = marker.key(1).time;
    t1 = key(1).time;
    t2 = key(2).time;
    if (time < tm)
    t = linear(time,t1,tm,t1,t2)
    else
    t = t2 + (time - tm);
    valueAtTime(t)

    Dan

  • Daniel Futerman

    November 13, 2015 at 8:18 am

    You’re simply amazing Dan. Thank you so much!!!

    After Effects Template & Photoshop Tutorials:
    https://www.amigo-productions.com

  • Daniel Futerman

    November 20, 2015 at 8:51 am

    Hi Dan,

    I’m trying to figure out a way to slightly adjust the result of the expression.

    What currently happens is that when dragging the marker to an earlier time, the animation speeds up between keyframe 1 & 2, and the speed between keyframes 2 & 3 stays the same. This is what I thought I wanted to happen.

    But.. this results in a smooth animation between keyframes 1 & 2, and then slows down between 2 & 3, causing a not-smooth movement.

    So bottom line is, I’d like the marker stimulate the “squeezing” (for lack of better word) of the keyframes as done while holding Alt and adjusting all keyframes.

    I’ve attached a .gif to demonstrate what I mean, hope it helps!! 🙂

    After Effects Template & Photoshop Tutorials:
    https://www.amigo-productions.com

  • Dan Ebberts

    November 20, 2015 at 7:11 pm

    Try it this way:

    tm = marker.key(1).time;
    t1 = key(1).time;
    t2 = key(numKeys).time;
    t = linear(time,t1,tm,t1,t2);
    valueAtTime(t)

    Dan

  • Daniel Futerman

    November 20, 2015 at 10:51 pm

    Dan you are a genius. Seriously – Thank you so much for your help, I truly appreciate it.

    The code works perfectly, there’s only one last thing I want to ask if possible to do –

    Is there a way to have the exact same expression, but instead of having the marker location ‘connected’ to the final keyframe marking the end of the animation, it would be connected to the second keyframe indicating the beginning of the out animation. Hope this still makes sense!

    So essentially, I guess it would be some sort of mixture between the two expressions? Because ideally, I would like the user to be able to quickly drag the marker on layer 1 to a new point in time (i.e. slower or faster animation speed), and then be able to drag layer 2 to the position of the marker – which marks the beginning of the out animation.

    See what I mean? I hope it’s possible to do 🙂 This picture might help to explain what I mean.

    After Effects Template & Photoshop Tutorials:
    https://www.amigo-productions.com

  • Dan Ebberts

    November 20, 2015 at 11:03 pm

    I’m confused. Isn’t that what the first expression does?

    Dan

  • Daniel Futerman

    November 20, 2015 at 11:30 pm

    Sorry I thought that might have been confusing 🙂 I’ll try to better explain what I mean.

    Yes that is what the first expression does, but then I have the problem of the fast speed between 1st & 2nd keyframes, and then slow again between the 2nd & 3rd keyframes.

    The second expression you wrote does exactly what I need in terms of the result. What I was hoping to change in it is that the marker itself will connect to keyframe #2 instead of #3.

    So essentially it’s having the marker connected the same way as in the first expression, but have the result the same as the second expression.

    Marker = Connected to second keyframe (i.e same as in the first expression, indicating the begining of the out animation).

    Result = The same as the second expression.

    New expression = a mixture between the two.

    What happens in action: The user moves the marker on layer #1, which results in the effect of expression #2. The user then drags layer #2 to the time point of layer #1’s marker, which results in a smooth transition between the two layers.

    Does that make things more clear? Or have I completely confused you now? Probably the second option 😉

    After Effects Template & Photoshop Tutorials:
    https://www.amigo-productions.com

Page 1 of 2

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