Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Merging two expressions together: changing start and duration

  • Merging two expressions together: changing start and duration

    Posted by Sam Catt on November 9, 2017 at 4:09 pm

    Hi there,

    So recently with the announced features from AE 2018 I was curious in creating a perfect template to increase the proficiency some of the more mundane tasks take to complete, especially lower thirds / call outs. So I have manged to stitch together two different expressions

    firstly, one which extends the time between 2 key frames

    holdTime =effect(“Slider Control”)(“Slider”);
    k1 = 1; // 1st hold keyframe
    k2 = 2; // 2nd hold keyframe
    p = thisProperty;
    t1 = p.key(k1).time;
    t2 = t1 + holdTime;
    if (time < t1)
    t = time
    else if (time < t2)
    t = linear(time,t1,t2,t1,p.key(k2).time)
    else
    t = p.key(k2).time + (time – t2);
    valueAtTime(t)

    secondly, one which changes the time in which the animation starts

    s =effect(“Slider Control2”)(“Slider”);
    t = time + s;
    valueAtTime(t)

    However, for the life of me I can’t seem to get them to work together, I’ve tried all sorts of things but to no avail.

    Anyway the situation is,

    I have a call out which has a short animation allowing it to pop onto the screen. After 10 seconds it then plays its outro animation in which its gone. Thats fantastic… if every single call out could be read or needed to last 10 seconds. However, I want this to be as dynamic as possible.

    I’ve connected it to a controll null with a slider, but for ease of use i’ve just added the slider to the actual object.

    All I want to do is be able to have 2 sliders, 1 which changes the duration that the animation between 2 key frames takes ( extending or decreasing my 10 second animation ) and a second slider which controls when this animation is played, increasing or decreasing the time in which the animation will start

    IE:
    time slider: 10
    delay slider: 30

    animation plays at 00:30:00 and lasts 10 seconds

    time slider: 20
    delay slider: 100

    animation plays at 01:40:00 and lasts 20 seconds


    holdTime =effect("Slider Control")("Slider");
    k1 = 1; // 1st hold keyframe
    k2 = 2; // 2nd hold keyframe
    p = thisProperty;
    t1 = p.key(k1).time;
    t2 = t1 + holdTime;
    if (time &lt; t1)
    t = time
    else if (time &lt; t2)
    t = linear(time,t1,t2,t1,p.key(k2).time)
    else
    t = p.key(k2).time + (time - t2);
    valueAtTime(t)

    s =effect("Slider Control2")("Slider");
    t = time + s;
    valueAtTime(t)

    Sam Catt replied 8 years, 6 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    November 9, 2017 at 5:01 pm

    Something like this should work:

    holdTime =effect(“Slider Control”)(“Slider”);
    offset = effect(“Slider Control 2”)(“Slider”);
    p = thisProperty;
    t1 = p.key(1).time + offset;
    t2 = t1 + holdTime;
    t = linear(time,t1,t2,p.key(1).time,p.key(2).time);
    valueAtTime(t)

    Dan

  • Sam Catt

    November 9, 2017 at 5:15 pm

    Hi dan thanks so much for this!

    It works like you said, and probably my description wasn’t good enough

    I adjusted it to match my needs

    there are a total of 4 key frames

    K1 > K2 in animation
    K2 > K3 holding position
    K3 > K4 out animation

    but if I change the key’s from 1 – 2 nothing happens
    and If i put them at 1 – 4 It changes the speed of the whole animation and not just the keyframes 2 – 3

    anyway to fix that?

    holdTime =effect("Slider Control")("Slider");
    offset = effect("Slider Control 2")("Slider");
    p = thisProperty;
    t1 = p.key(1).time + offset;
    t2 = t1 + holdTime;
    t = linear(time,t1,t2,p.key(2).time,p.key(3).time);
    valueAtTime(t)

  • Sam Catt

    November 14, 2017 at 5:19 pm

    Anybody have any ideas on how to do the above?

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