Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions jump to variables from slider

  • jump to variables from slider

    Posted by Mike Roberts on January 29, 2015 at 12:12 am

    hey guys,

    I’m trying to get a null to snap to 4 (or more) positions based on a slider value.

    The script I’m using is this:

    s = thisComp.layer(“COG”).effect(“Torso_Turn”)(“Slider”);
    a = [250,49.5];
    b = [450,49.5];
    c = [380,-30.5];
    if (s <10) linear(s,100,0,a,b);
    else linear(s,0,100,b,c);

    But what i need is for the position to “jump” to the positions instead of sliding to them. What’s the best way to say:

    If s = 0-25 then position “a”
    if s = 25-50 then position “b”
    if s = 50-75 then position “c”
    etc

    is there a simple way to do that?

    Mike Roberts replied 11 years, 3 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    January 29, 2015 at 12:26 am

    I haven’t tested it, but this should work:

    if (s < 25)
    a
    else if (s < 50)
    b
    else if (s < 75)
    c
    else
    d

    (you didn’t mention d, but the expression has to evaluate to something (or it will break) if the slider gets above 75.

    Dan

  • Mike Roberts

    January 29, 2015 at 2:31 am

    AH! That makes total sense! I’ll try it out!

    THANKS DAN

  • Mike Roberts

    January 29, 2015 at 9:18 pm

    Just a question out of interest – is there a way for it to work with negative numbers? So if the slider starts at -100 and goes to 100 how would you write that expression?

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