# Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Rotation with Opacity

• # Rotation with Opacity

Posted by on April 20, 2023 at 6:33 am

Good morning,

I want to make a layer have opacity 0 or 100 depending on the rotation of another layer. It is like a cover that is behind a spinning object.

I have solved it like this:

var rotationAvatar = thisComp.layer(“Control General Avatar”).transform.yRotation;

if (rotationAvatar > 52 && rotationAvatar < 310) {

100;

} else if (rotationAvatar > 52 + 360 && rotationAvatar < 310 + 360){

100;

} else if (rotationAvatar > 52 + 720 && rotationAvatar < 310 + 720){

100;

} else if (rotationAvatar > 52 + 1080 && rotationAvatar < 310 + 1080){

100;

} else {

0;

}

But this way I only have 3 laps solved.

I think I would have to do a for, but I am not able to solve it.

I would also like to have the possibility that the opacity does not jump from 0 to 100 at once but does a little interpolation.

Any ideas?

3 Members · 3 Replies
• 3 Replies
• ### Dan Ebberts

April 20, 2023 at 4:55 pm

Play around with this:

`var rotationAvatar = thisComp.layer("Control General Avatar").transform.yRotation%360;if (rotationAvatar < 181)  ease(rotationAvatar,52,82,0,100)else  ease(rotationAvatar,280,310,100,0)`
• ### Melissa Franch

April 25, 2023 at 7:51 am

You are magic! Thanks!

• ### Brie Clayton

April 25, 2023 at 3:03 pm

Thank you again, Dan!

We use anonymous cookies to give you the best experience we can.