6 Replies Latest reply on Apr 30, 2011 8:27 AM by Rick Gerard

    Expression in after effects



      Is there an expression which let me parent/synchronize two layer properties at different values.

      For example:

      Layer 1 value 90°

      Layer 2 value 180°

      and increasing by one unit (+1) should do this

      Layer 1 value 91°

      Layer 2 value 181°

      and so on...

      Thank you

        • 1. Re: Expression in after effects
          TimeRemapper Level 4

          Just parent (or tie expressions via the pickwhip) the two sources to a null (or the null's rotation if using expressions...or an angle control...etc...).

          1 person found this helpful
          • 2. Re: Expression in after effects
            Chic01taliano Level 1

            I'm still trying to sort it out. Besides, is it possible to parent to just one axis ?

            • 3. Re: Expression in after effects
              Mylenium Most Valuable Participant

              Yes! But seriously, start with the basics: http://www.motionscript.com. Trying to answer vague one-liner questions is no way to even begin to learn expressions when even the most basic concepts elude you.



              • 4. Re: Expression in after effects
                Rick Gerard Adobe Community Professional & MVP

                The big trick in learning how to use expressions is to remember a little middle school math. Basic algebra. You have certain reserved words like thisComp, thisComp.layer(layer name), rotation, position and certain math operators like +, - . MathPI.


                There are also words that gather information like index and value.


                Position, orientation, color, and a bunch of other values are arrays. Arrays are in square brackets. For example 3D layer position of 200, 200, 0 is written in an expression as [200, 200, 0] The first value in the expression is value[0], the second is value[1], the third is value[2]. This is important when you define variables for the array.


                You may define elements in the array like this:

                x = 200;

                y = value [1];

                z = 0;


                [x, y, z]


                This returns a position of 200, whatever value you set for the y property, and a z position of 0. IOW you can keyframe the position property but only the y value will change because y is taking it's value from the position keyframes.  There you go, the most confusing part of expressions has just been explained.


                Your problem is a simple one of adding 90º to the value of layer 1's rotation. Your expression for layer two should be:


                thisComp.layer(Layer 1).rotation + 90


                Using this expression the animation you keyframe in layer 1 will show up in layer 2 but the values will be 90º higher. You could also use the layer number or index as a multiplier. IOW, if you had a bunch of layers you'd want to rotate in increments of 10º you could write this expression:


                thisComp.layer(Layer 1). rotation + (10* index-1).


                If layer 1 was at 0º, layer 2 would be at 10º, layer 2 would be at 20º, layer 3 would be at 30º and so on providing layer 1 was at the top of the timeline and layer 3 was at the bottom. You should be able to figure out why.


                Hope this helps. It should also give you enough information to parent to one axis. Take a look at the position example that declares variables.

                • 5. Re: Expression in after effects
                  Chic01taliano Level 1

                  Thanks to Rick Gerard i am on the right way now.

                  I am trying to make an underwater scene with Redgiant Psunami.

                  Now the problem is that Psunami is a pseudo-3D layer so i must fake background movements along with the camera.

                  As you can see from the image, Psunami has got Tilt, Pan and Roll within the Camera dropdown menu, and that moves the background elements independently.

                  Above Psunami i put a ramp to simulate abyss below, and until now i have achieved to sync the ramp with the "Tilt" and that "Tilt" should then be child to an Y Axis of the camera.

                  Does that look good or is there a better way to achieve this ?



                  • 6. Re: Expression in after effects
                    Rick Gerard Adobe Community Professional & MVP

                    I'm not exactly sure what you're trying to do here. You might want to think about changing the blend mode of the ramp. You can also do a lot in Psunami directly to change the look of the water below.


                    Without taking the time to recreate your project I can't tell if the expressions are working. If you can move your camera and the ramp looks like it is maintaining the proper position then your expressions are fine.

                    1 person found this helpful