Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Moving position over time and wiggle position

  • Moving position over time and wiggle position

    Posted by Danial Monson-bergum on January 22, 2018 at 3:57 am

    Hi all!

    The content you all post on CC here is so beneficial. I always learn something new, thanks! This is my first time posting though. I’m new to AE and wet behind the ears using expressions.

    I’d like to use an expression to control the position of 2D layers of various duration in a 1920×1080/24fps composition, such that they enter the composition window from “off screen,” then remain in the center of the composition window and wiggle for a duration, and finally exit the composition window.

    My thought is that this may be accomplished with if/else. I think that if time is greater than or equal to the layer’s in point, then the layer should take a half a second to move from “off screen” to [960, 540]. Or else, if time is greater than or equal to half a second after the layer’s in point, then then the layer should wiggle. Or else, if time is greater than or equal to half a second before the layer’s out point, then the layer should move from [960, 540] to “off screen.”

    I’m guessing I’m off base, and I’m not even sure how to set this up if it is possible. (Note: it so happens that the layers are “staggered,” so the “exiting” motion could usefully employ the in point of one lesser index).

    Thanks for any suggestions, or for a reality check if need be. ????????

    Danial Monson-bergum replied 8 years, 3 months ago 2 Members · 2 Replies
  • 2 Replies
  • Matt Volp

    January 23, 2018 at 3:58 am

    This should do it:

    inDur = 0.5 // duration of in animation
    wiggleDur = 0.5; // duration of wiggle
    outDur = 0.5 // duration of out animation
    layerWidth = thisLayer.sourceRectAtTime().width; // layer width
    layerHeight = thisLayer.sourceRectAtTime().height; // layer height

    x = layerWidth – (layerWidth*1.5); // “off screen” x position
    y = layerHeight – (layerHeight*1.5); // ”off screen” y position

    if (time < inPoint+inDur)
    linear (time,inPoint,inPoint+inDur,[x,y],[960,540])
    else if (time > inPoint+inDur && time < inPoint+inDur+wiggleDur)
    wiggle (10,20); // arbitrary wiggle values
    else
    linear (time,outPoint,outPoint-outDur,[960,540],[x,y])

    Feel free to change the value of x and y depending on where you would like the “off screen” position to be.

    Assuming that the scale property of the layer you want to animate is set at 100%, the x and y “off screen” positions above will keep the layer perfectly on the edge of the comp, no matter how big the layer. For example, if you were to apply this to a shape layer and resize the shape inside the ‘contents’ parameters, it will automatically adjust.

    Obviously, the total layer duration will have to be exactly the sum of all the duration variables. In this case; 1.5 seconds.

    If you wanted to have the layer wiggle, regardless of time, between the in and out animation, then try this:

    inDur = 0.5 // duration of in animation
    outDur = 0.5 // duration of out animation
    layerWidth = thisLayer.sourceRectAtTime().width; // layer width
    layerHeight = thisLayer.sourceRectAtTime().height; // layer height

    x = layerWidth – (layerWidth*1.5); // “off screen” x position
    y = layerHeight – (layerHeight*1.5); // ”off screen” y position

    if (time < inPoint+inDur)
    linear (time,inPoint,inPoint+inDur,[x,y],[960,540])
    else if (time > inPoint+inDur && time < outPoint-outDur)
    wiggle (10,20); // arbitrary wiggle values
    else
    linear (time,outPoint,outPoint-outDur,[960,540],[x,y])

    This now works regardless of the layer duration.

    Matt

  • Danial Monson-bergum

    January 24, 2018 at 7:50 am

    This is very cool! I like how you delegate the offscreen positions with a variable. I worked hard on the little distance I got, but I was planning on leaving offscreen position embedded (maybe lost) in my linear expression. And the && operator is very helpful.

    Tons of thanks!

    (Looks like this) >>>>> https://drive.google.com/open?id=1t9Fy57BRyzEKxbR2gncfIAf55RADu58U

    t = inPoint + .5;
    x = linear(time, inPoint, t, -960, 960);

    [x, 540]

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy