Skip to main content
Participant
October 5, 2023
Answered

Looking for an expression to toggle multiple layers opacity on/off (no blinking or master control)

  • October 5, 2023
  • 1 reply
  • 408 views

Let's say that I want to animate a character's hand. For that I have drawn multiple hands doing different gestures that I have imported in After Effects as PNG. All the hands are in one precomp that I will animate alongside my character in my main comp.

Now, in my precomp I have all of the hands in the same spot and I need to have one visible at a time. So one hand at 100% opacity and the other at 0% opacity. I could do that manually, setting all the keyframe and painfully change them all if my main animation were to change.

 

But, I KNOW that I could set up a slider on a control layer and with an expression assign each value of the slider to a layer, wich would be at 100% opacity while the others would be at 0%. This way I could just move the slider with one keyframe and easily switch the layers.

 

Thanks in advance for the help, I cannot for the life of me find the expression I used last time or the project in wich I used it.

This topic has been closed for replies.
Correct answer Dan Ebberts

An opacity expression similar to this, probably:

s = thisComp.layer("Control").effect("Slider Control")("Slider");
Math.round(s) == index ? 100 : 0

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
October 5, 2023

An opacity expression similar to this, probably:

s = thisComp.layer("Control").effect("Slider Control")("Slider");
Math.round(s) == index ? 100 : 0
Participant
October 5, 2023

Thanks, I'll try that !