Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Control Animation Between Two Keyframes with a Slider

  • Control Animation Between Two Keyframes with a Slider

    Posted by Luke Regan on March 21, 2015 at 9:10 pm

    I have 72 layers all of which I’d like to “explode” from their starting position (A) to their ending position (B). I’ve animated each layers individual position, point A to point B so I have two position keyframes for each layer, their starting and ending point. When you playback the animation it’s pretty simple, 72 layers move from the center of the comp to the edge of the comp at the specified speeds.

    Now what I need to do is control the animation timing (not speed) of each of these layers with a single slider. I still want the layers to move from point A to point B as I’ve specified but I’d like to control the timing with hold keyframes, to start and stop the layers movement as they move from point A to point B. So if I move the slider from 0 to 100 all the shapes would move from their position A to their position B. And if I added hold keyframes to the slider, all the shapes would move from position A to a hold position and then continue on to position B. Essentially I’m trying to time-remap keyframes I guess.

    Am I thinking about this correctly or is their a better solution of “exploding” the layers? Appreciate any tips!

    Mauro Junior replied 7 years ago 8 Members · 18 Replies
  • 18 Replies
  • Dan Ebberts

    March 21, 2015 at 9:45 pm

    If you have a null named “control” with a slider, this expression should move a layer from position A to position B as the slider goes from 0 to 100:

    s = thisComp.layer(“control”).effect(“Slider Control”)(“Slider”);
    linear(s,0,100,key(1).value,key(2).value)

    Dan

  • Graham Macfarlane

    March 22, 2015 at 9:28 am

    Hi Luke,

    Try precomposing your 70 animated layers, then in the time line right click the precomp and chose time>enable time remapping

    The remapping keys should allow you to control the playback timing of the 70 layers.

    Graham Macfarlane
    3D | VFX
    http://www.elyarch.com

  • Luke Regan

    March 22, 2015 at 10:28 pm

    Thanks, either of these solutions work for what I’m trying to achieve. Guess it was pretty simple! It was a long day 🙂

  • Icaro Lobo

    February 3, 2016 at 2:27 pm

    Hi Dan, your expression works for me. But what if I had spatial bezier interpolation on the 2 keyframes? It doesn’t seem to work for me.

    Thanks.

  • Dan Ebberts

    February 3, 2016 at 4:53 pm

    Try it this way:

    s = thisComp.layer(“control”).effect(“Slider Control”)(“Slider”);
    t = linear(s,0,100,key(1).time,key(2).time)
    valueAtTime(t)

    Dan

  • Icaro Lobo

    February 3, 2016 at 6:15 pm

    Perfect, thank you!

  • Masan Yi

    June 10, 2016 at 6:17 am

    Hello Dan,

    I just read this forum thread looking for some help. I think your expressions really helped me get an idea of what I need but I’m still hitting a error. Basically what I’m trying to do is creating a slider that replaces 2 keyframes that are the same position but leaving the in keyframe and out keyframes alone it’s for a lower third template. Here is a link to a reference movie of what I’m trying to do here is the link:

    https://vimeo.com/170121406

  • Dan Ebberts

    June 10, 2016 at 1:27 pm

    Something like this maybe:

    s = effect(“Slider Control”)(“Slider”);
    x0 = key(1).value[0]
    dx = value[0] – x0;
    [x0 + dx*s/100,value[1]]

    Dan

  • Masan Yi

    June 10, 2016 at 2:35 pm

    This works perfectly!
    I had to change it up a bit for the first line but it actually works now…The only thing I couldn’t figure out is having the slider be at 0 instead of 100 but it’s good enough. Thank you so much Dan!

  • Saara Salminen

    August 11, 2018 at 11:16 pm

    Hi!
    I’m trying to reach something similar myself. A null has two sliders: one that controls an animation with spatial bezier interpolation, an one that controls a linear animation.
    I tried to combine both of the expressions Dan mentioned, but only the latter expression works, regardless of the order I put them in. If I try them out separately, they work perfectly.

    It looks like this:
    s = effect(“Slider1”)(“Slider”);
    t = linear(s,0,100,key(1).time,key(2).time)
    valueAtTime(t);

    f = effect(“Slider2”)(“Slider”);
    linear(f,0,100,key(3).value,key(4).value);

    Any ideas how to get them both to work? I’d also like to understand why it doesn’t work to start with.

Page 1 of 2

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