Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Control value of two keyframes with one slider.

  • Control value of two keyframes with one slider.

    Posted by Fabian Bosman on November 5, 2019 at 2:19 pm

    Hello After Effects masters,

    I’m creating a template in which the end user would be able to adjust a lowerthird to the length of a name he/she wants to use.

    I’ve made a simple in-animation and out animation.
    So this is my setup:
    Keyframe 1: 00:00 (value is 0)
    Keyframe 2: 02:00 (value is defined by the slider)
    Keyframe 3: 04:00 (value is defined by the slider)
    Keyframe 4: 06:00 (value is 0)

    What I want is one slider to control the value of keyframe 2 and 3.
    But it should not create a new keyframe if you adjust the slider, it will only adjust the value of those two keyframes.

    2019-11-0515_16_26-nvidiageforceoverlay.png

    What should be the expression for this?
    I’ve found this expression online but it is not working for my animation.

    I hope someone can help me.
    Thanks

    if (numKeys > 1){
    t1 = key(1).time;
    t2 = key(2).time;
    v1 = [95, 95]; //or if it's 3d [95, 95, 95]
    slider = comp("INPUT").layer("CONTROL").effect("Zoom intensity")("Slider");
    v2 = [slider, slider]; // or [slider,slider,slider] if 3D
    linear((time, t1, t2, v1, v2);
    } else {
    value
    }

    Fabian Bosman replied 6 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    November 5, 2019 at 3:05 pm

    I think it will be something like this:


    s = thisComp.layer("Control").effect("Your Slider")("Slider");
    t1 = key(1).time;
    t2 = key(2).time;
    t4 = key(4).time;
    if (time > t1 && time < t4)
    value*s/valueAtTime(t2)
    else
    value;

    Dan

  • Fabian Bosman

    November 23, 2019 at 3:50 pm

    Dan, you are da man ☺
    Thank you for the expression, it was exactly what I was looking for.

    I want to understand what is going on in the code and how it works ☺

    Can you explain how I can customize it?
    So for example, I want keyframe 2 and 3 and 5 to look at the slider value.
    How does that work.

    Greetz,
    Fabian

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