ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Linking opacity to rotation

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Oskari Gronroos
Linking opacity to rotation
on Sep 28, 2017 at 2:28:05 pm

I have the following expression (adapted from this thread) on an opacity parameter, linking the rotation of a null to the opacity, so it fades in and out when the null approaches a specific angle (a).

This does precisely what I want, but has two problems.

  1. If a = 0, and the null animates from 0x+315.0° to 1x+0.0° (or from 0x-315.0° to -1x+0.0°), the opacity will remain at 0 until the revolution has been completed, and only then pops into 100%.

  2. If the rotation of Null 1 is negative, it treats a as if it's a positive integer. So for instance, if rotation is 0x-270.0, the object where a=270 will be at 100% opacity (instead of a=90, like would make sense)

How can I address these two issues? I've tried a lot of different Math.abses and modulos, but I can't figure it out.

var a = 45;
var r = Math.abs((thisComp.layer("Null 1").transform.zRotation)%360);
var d = Math.abs(a-r);
ease(d, 10,36, 100,0);

Return to posts index

Dan Ebberts
Re: Linking opacity to rotation
on Sep 28, 2017 at 5:24:52 pm

Try this:

a = 45;
r = thisComp.layer("Null 1").transform.zRotation;
d = (r - a)%360;
if (d > 180) d -= 360;
if (d < -180) d += 360;
ease(Math.abs(d), 10,36, 100,0);


Return to posts index

Oskari Gronroos
Re: Linking opacity to rotation
on Sep 29, 2017 at 8:38:52 am

Brilliant! Thank you so much, that's just the job!

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved