Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions multiple linear() expressions in a row

  • multiple linear() expressions in a row

    Posted by Alex Weil on January 17, 2020 at 4:54 pm

    hey guys

    i have a slider and several position keyframes (on a null). now i want to move from key(1) to key(2) when slider slides from 0 – 25 … no problem … but from 25-50 it should move from key(2) to key(3) … okay second linear() expression… i multiplied it all like this:

    s = effect("Slider Control")("Slider");
    p = transform.position;
    linear(s,0,25,p.key(1),p.key(2))+
    linear(s,25,50,p.key(2),p.key(3))+
    linear(s,50,75,p.key(3),p.key(4))+
    linear(s,75,100,p.key(4),p.key(5))

    so i summarized the linear expressions together but then my null goes crazy like all the key() get summarized :-/

    Alex Weil replied 6 years, 3 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    January 17, 2020 at 5:33 pm

    See if this works for you:


    s = effect("Slider Control")("Slider").value;
    if (s <= 25){
    t = linear(s,0,25,key(1).time,key(2).time);
    }else if (s <=50){
    t = linear(s,25,50,key(2).time,key(3).time);
    }else if (s <= 75){
    t = linear(s,50,75,key(3).time,key(4).time);
    }else{
    t = linear(s,75,100,key(4).time,key(5).time);
    }
    valueAtTime(t)

    Dan

  • Alex Weil

    January 20, 2020 at 11:17 am

    sweet ☺ tried something similar with if/else conditions but didnt know about doing it with t=linear(…. and valueAtTime(t) ☺ this works great! thank you

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