ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Grid Element Position to

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jonas Karten
Grid Element Position to
on Apr 30, 2019 at 2:46:45 pm

Hello!

I'm new to expressions and not sure how to achieve the following:

I have a grid of small circles (shape layers) with 20 columns and 11 rows. In the animation, I want one circle in the grid ("leader") to be the target position for all the other elements of the grid: the animation would start as a grid and end in one circle. Every circle would have a keyframed starting position and an get the end position from the "leader", probably through an expression or a keyframe.

If all the grid elements just use the leaders end position keyframe, it's doing not quite the effect I want. The further the circles are away from the leader, the faster they move, since the end keyframe is always the same.

- How can I achieve some kind of "speed limit" for the circles? The further they are away, the longer they should need to reach the end position. Is there an expression I can apply to the position change (and without losing easing)?

Any help or links to tutorials would be appreciated!

- Is there a way to let an element change it's position from a given keyframe to the leaders position without a second keyframe? Like an attractor-expression?


Return to posts index

Kalleheikki Kannisto
Re: Grid Element Position to
on May 1, 2019 at 6:21:58 am

Might not be that easy if you're new to expressions, but the basic idea would be this, no keyframes needed (necessarily).

"Time" is variable that changes, and it changes at an even pace. The other variable that applies to how fast the objects should move is their original distance from the end point. So you would want to remap time into position, taking into account how far the object originally is.

One of the key things is my favorite expression linear() or ease(), which remaps one thing to another with or without easing. Take linear for sake of simplicity. You would remap time to position between origin and target. This might be easier to approach as a percentage of position between origin and target. Thus, using descriptive variable names:

linear(time, starttime, starttime+distance, 0, 100)

Where 0 and 100 are the origin point and target point respectively. In other words, the percentage of target point in the calculation is 0 at the beginning and 100 at the end.

Follow so far?

You could, of course just use the origin point and target point, but those are two-dimensional arrays rather than variables, so this is a sightly easier method in that aspect.

To make an expression out of this, you would have define "starttime", and calculate "distance" from origin to target.

You would get the percentage as a result, and then it would be a matter of calculating the current position with that percentage.

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Jonas Karten
Re: Grid Element Position to
on May 2, 2019 at 9:36:23 am

Thank you very much for this detailed answer! I have to admit I didn't expect it would be so complicated, this is a bit over my head.

With the right keywords ("constant speed" instead of "max speed") I've found and older thread with a similar problem. With the help of a slider control and roving keyframes, the script creates a constant speed. I changed "linear" to "ease" and I believe it now does what I want.

if (numKeys > 1){
spd = thisComp.layer("control").effect("Slider Control")("Slider");
t1 = key(1).time;
t2 = key(numKeys).time;
tTot = t2-t1;
dTot = speedAtTime(t1)*tTot;
deltaT = time - t1;
valueAtTime(linear(deltaT*spd,0,dTot,t1,t2))
}else
value


Return to posts index

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