8 Replies Latest reply on Jul 23, 2018 3:56 PM by bryan.gough

    Expression with delay

    SolidPP Level 1

      Hi,

       

      I'm a nooby when it comes to expression, so can anyone please help me with how I can create a certain expression?

       

      I think it's quite simple. I've got 2 layers. One layer has an animation (leader) and the other one needs to follow. Only with a delay of 1 frame. The animations happens on "position", "scale" and "rotation".

       

      Thanks you very much in advance!

       

      Best regards,

       

      John

        • 1. Re: Expression with delay
          Dan Ebberts Level 5

          These should work:

           

           

          thisComp.layer("leader").transform.position.valueAtTime(time-thisComp.frameDuration)

           

           

          thisComp.layer("leader").transform.scale.valueAtTime(time-thisComp.frameDuration)

           

           

          thisComp.layer("leader").transform.rotation.valueAtTime(time-thisComp.frameDuration)

           

           

          Dan

          • 2. Re: Expression with delay
            SolidPP Level 1

            Hi Dan!

             

            this really helps! Thank you so much.

             

            Only one more question, because how can I change the number of frames it delays on this expression?

             

            Best regards,

             

            John

            • 3. Re: Expression with delay
              Dan Ebberts Level 5

              This should work:

               

              delayFrames = 3;

              delay = framesToTime(delayFrames);

              thisComp.layer("leader").transform.position.valueAtTime(time-delay)

               

               

              Dan

              3 people found this helpful
              • 4. Re: Expression with delay
                SolidPP Level 1

                Again this works perfect! Thank you!

                • 5. Re: Expression with delay
                  Mathias Möhl Level 2

                  These kinds of delays can also be done easily with mamoworld's iExpressions for After Effects.

                  This requires no code writing at all:

                   

                  • 6. Re: Expression with delay
                    bryan.gough Level 1

                    Dan, it's been 4 years since this originally was posted... but I'm just finding it!

                    I want to use the "leader" layer to control multiple objects. I have three boxes on screen and one Null (leader).

                    The Null's Y position is keyframed to move onto the screen from the bottom.

                     

                    I want box #1 to come on with a delay (as explained above) which works fine.

                    I want box #2 to come on with a slightly longer delay (easy enough), but I want it to come down from the top of the screen: to mirror the Null's motion.

                     

                    I know that there's probably 5 year olds out there that can do this for me... but, I'm at the office.

                    • 7. Re: Expression with delay
                      jeromedamey_kickback Level 1

                      Hey Bryan, I don't know if you'd still care for a solution, as it has been a few years since you inquired.

                      I just stumbled upon this thread while looking for some answers for a different question of mine, but I recognized your name... Maybe you are a relative of one of my in-laws. I can't quite put my finger on it.

                       

                      Anyways!

                       

                      I'll start with my expression for the delay. I went with a "daisy-chain" expression in which the layer references other layers in respect to itself (index).  The leader object contains the motion and no expression controls.

                      All layers below use this expression:

                       

                      thisComp.layer(index-1).transform.position.valueAtTime(time-delay);

                       

                      I used a slider to control my delay. Here's a screenshot of my timeline.

                      Screen Shot 2018-07-13 at 10.51.03 AM.png

                      Here's the delay in action.

                       

                      Now, to answer your question. You would like to keep the motion and delay, but have the object enter from the opposing side of the screen. This can be done by parenting that layer to a Null object. With the null, you can adjust any of the delayed layer's transform elements without effecting the delay expression.

                      In my example, I had to adjust my anchor point in order to center the layer where I wanted it.

                      Here is a screen shot of my timeline.

                       

                      Screen Shot 2018-07-13 at 10.54.25 AM.png

                       

                      And finally here it is in action.

                       

                       

                      Like everything After Effects related, I'm sure there are a few different ways to skin this cat.

                      If you have questions, lemme know!

                       

                      Hope this helps you out Bryan or really, anybody!

                      3 people found this helpful
                      • 8. Re: Expression with delay
                        bryan.gough Level 1

                        Interesting — there are a few Goughs out there, but it's not super common.

                        Also, it's a famous street name in San Francisco.

                         

                        Thanks for taking time to work through this—it HAS been a while, so I can't even remember what this was for!?