Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression “works” but not as intended.

  • Expression “works” but not as intended.

    Posted by Justin Maloney on May 25, 2016 at 3:57 pm

    So I’m working on a rig for work and I’d like a layer to only appear (via opacity) when certain conditions are met and not appear when other conditions are met.

    Basically, if a layer moves past a certain point, it turns on. If a certain switch is checked, it turns on, and if another different switch is checked, it turns off.

    I’ve done similar things with other layers and it works just fine, but I think here I have too many conditions and AE is getting confused.

    Any suggestions? Thanks =D

    x = thisComp.layer("OPTIONS").effect("Skelotor Mode")("Checkbox");
    b = thisComp.layer("Body Turn").transform.xPosition;
    f = thisComp.layer("C_L hand").effect("Force in Back L")("Checkbox");
    v = value;

    if (b < -10) v =100;
    else if (x == 0) v = 100;
    else if (f ==1) v = 100;

    else v = 0;

    Justin Maloney replied 10 years, 3 months ago 2 Members · 7 Replies
  • 7 Replies
  • Justin Maloney

    May 25, 2016 at 4:10 pm

    Sorry, basically the problem is that the opacity for the layer remains fixed at 100, or if I reverse the values and end with “else if v = 100” it remains fixed at 0.

    Also the first if is supposed to be “if (b < -10) v = 100;”

  • Justin Maloney

    May 25, 2016 at 4:20 pm

    Figured it out. Removed the multiple “else if’s” and moved the position conditional to the bottom. It looks like this…

    x = thisComp.layer(“OPTIONS”).effect(“Skelotor Mode”)(“Checkbox”);
    b = thisComp.layer(“Body Turn”).transform.xPosition;
    f = thisComp.layer(“C_L hand”).effect(“Force in Back L”)(“Checkbox”);
    v = value;

    if (x == 0) v = 100;
    if (f ==1) v = 100;
    if (b < -10) v =100;
    else v = 0;

    Better question: I’ve tried arrays before, but I can’t wrap my head around all the time. Would an array be better for expressions like this one?

  • Justin Maloney

    May 25, 2016 at 4:21 pm

    Nope! Nevermind, doesn’t work. God damn, sorry for premature replies…

  • Dan Ebberts

    May 25, 2016 at 4:35 pm

    You could restructure it like this:


    x = thisComp.layer("OPTIONS").effect("Skelotor Mode")("Checkbox");
    b = thisComp.layer("Body Turn").transform.xPosition;
    f = thisComp.layer("C_L hand").effect("Force in Back L")("Checkbox");

    if ((b < -10) || (x == 0) || (f ==1))
    v =100
    else
    v = 0;

    But you might need to revise it based on the priority of your controls. For example, what should happen if both checkboxes are on?

    Dan

  • Justin Maloney

    May 25, 2016 at 4:49 pm

    Skelotor Mode just brings in a wire frame model and turns off all the assets. I really need to keep this in so the other animators can work with this character rig at a steady pace.

    Any condition where “x” == 1 should set opacity to o%

    This expression is working better then what I had. Thanks man. I’ll keep tinkering!

  • Dan Ebberts

    May 25, 2016 at 4:54 pm

    This might be closer then:


    x = thisComp.layer("OPTIONS").effect("Skelotor Mode")("Checkbox");
    b = thisComp.layer("Body Turn").transform.xPosition;
    f = thisComp.layer("C_L hand").effect("Force in Back L")("Checkbox");

    if (x == 1)
    v = 0
    else if ((b < -10) || (f ==1))
    v =100
    else
    v = 0;

    Dan

  • Justin Maloney

    May 25, 2016 at 5:12 pm

    Dan, you are a god among animators. That worked perfectly.

    Many thanks!

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