ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Moving position over time and wiggle position

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Danial Monson-Bergum
Moving position over time and wiggle position
on Jan 22, 2018 at 3:57:26 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 1920x1080/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. 🐮😳


Return to posts index

Matt Volp
Re: Moving position over time and wiggle position
on Jan 23, 2018 at 3:58:17 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


Return to posts index

Danial Monson-Bergum
Re: Moving position over time and wiggle position
on Jan 24, 2018 at 7:50:11 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]


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]