Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Trigger animation based on hold keyframe?

  • Trigger animation based on hold keyframe?

    Posted by Graham Quince on December 28, 2020 at 10:02 am

    I’ve got a highlighter I use in my videos, which uses layer markers to animate opactiy, but I also have to set a position property with a hold keyframe to have the highlight appear in the right place.

    fadetime = 0.5;
    dur = 2;
    if(marker.numKeys > 0){
    m = marker.nearestKey(time).index;
    if(marker.key(m).time > time) {
    m--;
    }
    if(m > 0){
    mt = marker.key(m).time;
    if(time < mt+dur){
    linear(time, mt, mt+fadetime, 0, 100);
    } else {
    linear(time, mt+dur, mt+dur+fadetime, 100, 0);
    }
    } else {
    0
    }
    } else { 0
    }

    I’m wondering if there’s a way to trigger the animation based on the change of position keyframe value instead of the layer marker. It’s hardly an onerous task, but I’m curious if it’s possible.

    Graham Quince replied 3 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    December 28, 2020 at 5:15 pm

    This should work:

    fadetime = 0.5;

    dur = 2;

    p = position;

    val = 0;

    if(p.numKeys > 0){

    n = p.nearestKey(time).index;

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

    n--;

    }

    if(n > 0){

    t = p.key(n).time;

    if(time < t+dur){

    val = linear(time, t, t+fadetime, 0, 100);

    } else {

    val = linear(time, t+dur, t+dur+fadetime, 100, 0);

    }

    }

    }

    val

  • Graham Quince

    December 30, 2020 at 12:35 pm

    Wonderful. Thank you.

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