ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Control Animation Between Two Keyframes with a Slider

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Luke Regan
Control Animation Between Two Keyframes with a Slider
on Mar 21, 2015 at 9:10:40 pm

I have 72 layers all of which I'd like to "explode" from their starting position (A) to their ending position (B). I've animated each layers individual position, point A to point B so I have two position keyframes for each layer, their starting and ending point. When you playback the animation it's pretty simple, 72 layers move from the center of the comp to the edge of the comp at the specified speeds.

Now what I need to do is control the animation timing (not speed) of each of these layers with a single slider. I still want the layers to move from point A to point B as I've specified but I'd like to control the timing with hold keyframes, to start and stop the layers movement as they move from point A to point B. So if I move the slider from 0 to 100 all the shapes would move from their position A to their position B. And if I added hold keyframes to the slider, all the shapes would move from position A to a hold position and then continue on to position B. Essentially I'm trying to time-remap keyframes I guess.

Am I thinking about this correctly or is their a better solution of "exploding" the layers? Appreciate any tips!


Return to posts index

Dan Ebberts
Re: Control Animation Between Two Keyframes with a Slider
on Mar 21, 2015 at 9:45:50 pm

If you have a null named "control" with a slider, this expression should move a layer from position A to position B as the slider goes from 0 to 100:

s = thisComp.layer("control").effect("Slider Control")("Slider");
linear(s,0,100,key(1).value,key(2).value)


Dan



Return to posts index

Icaro Lobo
Re: Control Animation Between Two Keyframes with a Slider
on Feb 3, 2016 at 2:27:59 pm

Hi Dan, your expression works for me. But what if I had spatial bezier interpolation on the 2 keyframes? It doesn't seem to work for me.

Thanks.


Return to posts index


Dan Ebberts
Re: Control Animation Between Two Keyframes with a Slider
on Feb 3, 2016 at 4:53:47 pm

Try it this way:

s = thisComp.layer("control").effect("Slider Control")("Slider");
t = linear(s,0,100,key(1).time,key(2).time)
valueAtTime(t)


Dan



Return to posts index

Icaro Lobo
Re: Control Animation Between Two Keyframes with a Slider
on Feb 3, 2016 at 6:15:15 pm

Perfect, thank you!


Return to posts index

Saara Salminen
Re: Control Animation Between Two Keyframes with a Slider
on Aug 11, 2018 at 11:16:18 pm

Hi!
I'm trying to reach something similar myself. A null has two sliders: one that controls an animation with spatial bezier interpolation, an one that controls a linear animation.
I tried to combine both of the expressions Dan mentioned, but only the latter expression works, regardless of the order I put them in. If I try them out separately, they work perfectly.

It looks like this:
s = effect("Slider1")("Slider");
t = linear(s,0,100,key(1).time,key(2).time)
valueAtTime(t);

f = effect("Slider2")("Slider");
linear(f,0,100,key(3).value,key(4).value);

Any ideas how to get them both to work? I'd also like to understand why it doesn't work to start with.


Return to posts index


Dan Ebberts
Re: Control Animation Between Two Keyframes with a Slider
on Aug 11, 2018 at 11:58:20 pm

You can't combine expressions but just putting one after the other. Only the last statement executed will have any effect. You have to blend the expressions somehow. What determines the timing of how the two sliders are supposed to interact?


Dan



Return to posts index

Saara Salminen
Re: Control Animation Between Two Keyframes with a Slider
on Aug 12, 2018 at 3:15:31 pm

Hi Dan!
Oh, I was afraid so.
The first slider controls an animation where an object moves upwards along a curve. The animation controlled by the second slider is linear along the x-axis.
The goal is to create a controller that controls both the sliders. When the controller moves vertically, the first slider activates, and when moving the controller horizontally, the second slider is activated. It's all part of a rig.


Return to posts index

Dan Ebberts
Re: Control Animation Between Two Keyframes with a Slider
on Aug 12, 2018 at 3:24:16 pm

From that description, it sounds like it might be like this, but I'm afraid I'm missing something:

s = effect("Slider1")("Slider").value;
f = effect("Slider2")("Slider").value;
[f,s]

Dan



Return to posts index


Saara Salminen
Re: Control Animation Between Two Keyframes with a Slider
on Aug 12, 2018 at 3:52:08 pm

Now the sliders move the object along each axis, but ignore the position animation they are supposed to control. Let me try to explain with an image:


So I've got a null object (called "Null_pyrstö_V") with two sliders. The null's position is animated, so that between the two first keyframes, the null moves in an arch. The third keyframe has the same position as the first. Between the third and the fourth keyframe the null moves in a straight line.
I'd like the first slider, called "Kaari", to controll the animation between the two first keyframes. So that when the slider is moved, the null moves from keyframe1 to keyframe2.
The second slider, called "vaakataso", is supposed to make the null go from the third keyframe to the fourth. So I need to find a way to combine the expressions, so that both sliders work, and I could later link them to a controller.


Return to posts index

Dan Ebberts
Re: Control Animation Between Two Keyframes with a Slider
on Aug 12, 2018 at 4:45:41 pm

I still don't quite get it, but maybe like this:


if (time < key(2).time){
s = effect("Slider1")("Slider");
t = linear(s,0,100,key(1).time,key(2).time)
valueAtTime(t);
}else{
f = effect("Slider2")("Slider");
linear(f,0,100,key(3).value,key(4).value);
}



Dan



Return to posts index

Kalleheikki Kannisto
Re: Control Animation Between Two Keyframes with a Slider
on Aug 13, 2018 at 7:42:30 am
Last Edited By Kalleheikki Kannisto on Aug 13, 2018 at 8:08:52 am

Do you want to add the values together so that you get both motions with your controller, the horizontal motion with the x value plus the arched vertical motion with the y value combined at the same time? So as to control this animation completely with the controller, ignoring actual timeline time altogether?

If that's the aim, you could do it like this. In this implementation the keyframes are exactly at 0,1,2 and 3 seconds and there's a layer named "controller" with a 3D point controller on it. This adds the two motions together. 0-100 range for both x and y animations.

controller = thisComp.layer("controller").effect("3D Point Control")("3D Point");
c_x = controller[0];
c_y = controller[1];
t1 = linear(c_x,0,100,0,1);
t2 = linear(c_y,0,100,2,3);
pos1 = transform.position.valueAtTime(t1);
pos2 = transform.position.valueAtTime(t2)-transform.position.valueAtTime(2);
pos = pos1+pos2;


Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index


Saara Salminen
Re: Control Animation Between Two Keyframes with a Slider
on Aug 13, 2018 at 10:40:01 am

Yes, that's exactly what I was trying to achieve! Works like a charm.
Kiitos ☺


Return to posts index

Graham Macfarlane
Re: Control Animation Between Two Keyframes with a Slider
on Mar 22, 2015 at 9:28:10 am

Hi Luke,

Try precomposing your 70 animated layers, then in the time line right click the precomp and chose time>enable time remapping

The remapping keys should allow you to control the playback timing of the 70 layers.

Graham Macfarlane
3D | VFX
http://www.elyarch.com




Return to posts index

Luke Regan
Re: Control Animation Between Two Keyframes with a Slider
on Mar 22, 2015 at 10:28:14 pm

Thanks, either of these solutions work for what I'm trying to achieve. Guess it was pretty simple! It was a long day :)


Return to posts index


Masan Yi
Re: Control Animation Between Two Keyframes with a Slider
on Jun 10, 2016 at 6:17:02 am

Hello Dan,

I just read this forum thread looking for some help. I think your expressions really helped me get an idea of what I need but I'm still hitting a error. Basically what I'm trying to do is creating a slider that replaces 2 keyframes that are the same position but leaving the in keyframe and out keyframes alone it's for a lower third template. Here is a link to a reference movie of what I'm trying to do here is the link:



Return to posts index

Dan Ebberts
Re: Control Animation Between Two Keyframes with a Slider
on Jun 10, 2016 at 1:27:07 pm

Something like this maybe:

s = effect("Slider Control")("Slider");
x0 = key(1).value[0]
dx = value[0] - x0;
[x0 + dx*s/100,value[1]]


Dan



Return to posts index

Masan Yi
Re: Control Animation Between Two Keyframes with a Slider
on Jun 10, 2016 at 2:35:38 pm

This works perfectly!
I had to change it up a bit for the first line but it actually works now...The only thing I couldn't figure out is having the slider be at 0 instead of 100 but it's good enough. Thank you so much Dan!


Return to posts index

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