Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions sliders to control time between keyframes

  • sliders to control time between keyframes

    Posted by Mike Throck on June 11, 2011 at 4:05 am

    I have an object that moves from one place to another, holds there and then moves to another location and scales up.

    I’d like to control the amount of time it holds with an expression slider, and not have to move any of the scale keyframes.

    I’m not very experienced with expressions, so any help is appreciated.

    Hung Nguyendac replied 11 years, 4 months ago 5 Members · 21 Replies
  • 21 Replies
  • Dan Ebberts

    June 11, 2011 at 2:31 pm

    I’m not sure if this is exactly what you’re after, but you would apply this expression to both the position and scale properties. It’s set up to substitute the slider value for the time between position keyframes 2 and 3 (change the values of k1 and k2 if it should be a different pair):


    holdTime = effect("Slider Control")("Slider");
    k1 = 2; // 1st hold keyframe
    k2 = 3; // 2nd hold keyframe
    p = transform.position;
    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)

    Dan

  • Mike Throck

    June 11, 2011 at 6:52 pm

    This is exactly what I needed, thank you much! It even still recognizes the easy ease.

  • Mike Throck

    June 11, 2011 at 9:50 pm

    Your answer was so helpful, I was hoping you could help me add one more element.

    As the object scales up I want it’s parent object’s ( a null) Y position to animate in time as well. The expression you already gave me would do this, but I would like the value of the Y position to be controlled by a slider as well.

    How do I get the Null’s second keyframe to be driven by a slider and still work with the other expression.

    you are the man, of course.

  • Dan Ebberts

    June 11, 2011 at 10:31 pm

    OK, you lost me. I thougt I was with you until you mentioned the null’s 2nd keyframe. Are you just talking about adding the value of the slider to the null’s y position, or is this another timing-control slider?

    Dan

  • Mike Throck

    June 11, 2011 at 10:37 pm

    I guess what I’m after is this:

    I’d like the anchor point, scale and posY to be controlled by sliders but I’d like to just enter a value and not have to adjust keyframes.

    Much like the time between them is controlled by a slider where I enter a number. Is it possible to have a slider determine one keyframes value but not the other?

  • Dan Ebberts

    June 12, 2011 at 12:01 am

    So you want to be able to substitute a value at a particular keyframe, is that correct? If so, which one, the last one?

    Dan

  • Mike Throck

    June 12, 2011 at 12:24 am

    Yes, and the second of the 2 keyframes.

    I basically want to be able to change the value of a keyframe using a slider control, without having to scrub to that point in time.

  • Dan Ebberts

    June 12, 2011 at 12:59 am

    The only way I can think of would lose any easing or deviation you had built into the keyframes. It would go straight from the value at keyframe 1 to the slider value, using the timing generated with the previous expression. Is it still worth doing?

    Dan

  • Mike Throck

    June 12, 2011 at 1:03 am

    I guess not, the easing is important.

    I’m building a template for people who don’t know after effects very well and I wanted to make it as easy to use as possible.

    Thanks for all your help, especially on a Saturday!

  • Lukasz Lindell

    June 15, 2011 at 1:23 pm

    holdTime = effect("Slider Control")("Slider");
    k1 = 2; // 1st hold keyframe
    k2 = 3; // 2nd hold keyframe
    p = transform.position;
    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)

    Hijacking this thread a litte, but this was exactly what I was after. I tried to add more keyframes to hold, up to 10. I started out with adding to the:

    k1 = 2; // 1st hold keyframe
    k2 = 3; // 2nd hold keyframe

    and created:

    k3 = 4; // 3rd hold keyframe

    and so on, up to k10. Then I added:

    t3 = t2 + holdTime;
    t4 = t3 + holdTime;

    Guess I’m doing fine so far, but here my little skills ended. How do I keep on adding to this expression? This part really messed it up for me:

    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);

    Dont know where to go from here though…

Page 1 of 3

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