ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression to define two positions, tween back and forth

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Benjamin AllisonExpression to define two positions, tween back and forth
by on Jan 30, 2014 at 10:13:50 pm

So I want to do something simple: define two sets of coordinates (a "from" and a "to" position), along with a duration in frames. I want the animation to be executed, then reversed, and looped.

I know I can set two keyframes, and use `loopOut("pingPong");` but I want to try and achieve this with a simple expression.

I'm sure it's possible!


Return to posts index

Darby EdelenRe: Expression to define two positions, tween back and forth
by on Jan 30, 2014 at 10:39:45 pm

[Benjamin Allison] "I know I can set two keyframes, and use `loopOut("pingPong");` but I want to try and achieve this with a simple expression."

loopOut("pingpong") is a simple expression! :)

You won't be able to define any spatial paths any other way, but this should work:

d = 5;
fd = d * 2;
p1 = [200, 500];
p2 = [500, 200];
t = (time - inPoint) % fd;

if(t <= d) linear(t, 0, d, p1, p2);
else linear(t, d, fd, p2, p1);


This starts from p1 at the beginning of the layer and runs to p2 over 5 seconds, then goes back to p1 and begins again. If you want the animation to ease in to each point you could use the ease() function instead of linear() providing the same arguments.

-Darby

Darby Edelen


Return to posts index

Benjamin AllisonRe: Expression to define two positions, tween back and forth
by on Jan 30, 2014 at 10:46:24 pm

You're a king among men!

The concept is so simple I can't believe an hour of googling got me zilch.

Thanks so much Darby!


Return to posts index

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