Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Variable 2nd position keyframe. (first one is locked)

  • Variable 2nd position keyframe. (first one is locked)

    Posted by Rob Nairn on September 24, 2020 at 6:15 am

    Hi everyone,

    I’m creating some mogrts. I’d like one of the available variables to control the x position of the 2nd key frame of an object.

    In other words I want it to always start at the same place, but be able control where it goes to horizontally, via a slider control.

    I’ve done some searching and nothing I’ve found seems to fit the bill.

    Thanks in advance.

    Rob Nairn replied 5 years, 7 months ago 3 Members · 5 Replies
  • 5 Replies
  • Chris Voelz

    September 24, 2020 at 2:58 pm

    Try setting the second keyframe to the max position for your comp and then use the slider to offset the value?

  • Rob Nairn

    September 24, 2020 at 11:43 pm

    Hi Chris,

    I’m getting stuck writing an expression where the slider only controls that second keyframe rather than both.

  • Stephen Dixon

    September 25, 2020 at 12:53 am

    Using an interpolation function like linear() will allow you to transition from one value to another over time. E.G.:

    let kf1 = transform.position.key(1);
    let kf2 = transform.position.key(2);
    linear(kf1.time, kf2.time, kf1.value, [sliderVal, kf2.value[1]])

    You could also use ease(), easeIn() or easeOut() in place of linear, for smoothly eased motion.

  • Chris Voelz

    September 25, 2020 at 4:01 pm

    It took me minute to wrap my head around this, i’ve never used the key() before. After testing I was able to get this to work well for me.

    p = thisLayer.transform.position[0];

    k1 = key(1).value[0];

    k2 = key(2).value[0];

    v = k2 + effect("Slider Control")("Slider");

    [linear(p,k1,k2,k1,v),540]

  • Rob Nairn

    September 27, 2020 at 11:22 pm

    Thanks Chris and Stephen. I’ll give these a go, thanks for your help so far.

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