- [Evan] This is Evan Abrams and in this After Effects
tutorial, we're looking at one of my most commonly used
expressions in After Effects, it's the value at time expression. Now I'm hoping that this
tutorial will give you a lot of value for your time. Yikes, brutal puns. We're gonna talk about
what the expression does, how to use it and we're gonna check out a few examples to hopefully
inspire your journey to get a little deeper into expressions. So please, follow along
and we'll get into it without delay, that is two
more pretty brutal puns which will probably make more
sense after the tutorial. Anyway, I'm Evan Abrams,
this is the value at time expression in Adobe After Effects. (intense music) All right, so as you saw on the intro, we've had this wonderful
trail of circles goin' around, and thanks to the value
at time expression, I only had to put key
frames on one of them, and all the others follow along because they're all referencing the value of that first leader at different times. So it's one of the fun things we can do with this expression. But what is it really doing? What does value at time mean? Well, here's our first example. We're looking at this
wonderful clock situation. We have key frames set on
the rotation of this pointer. So the pointer is turning around. And let's say the rotation
is gonna start here at zero. So at zero seconds, the value
of the rotation is zero. And here at five seconds, the
value of the rotation is five. We can tell because we've
put key frames on it. So we've chosen those values,
now with these followers, these little lines here,
and really all they are, these followers, just this layer here. So if we rotate it around,
we'll end up with these kind of cardinal points,
these clock points. I'm gonna hit EE to call up the expression that we've written on the
rotation of that follower. And what we've written is thisComp.layer, meaning inside this
comp, look for a layer, and which layer specifically? Well, in this argument in
these parenthesis for the layer we're saying, look at
the layer named pointer and then dot, or more specifically, look into its transform, more
specifically, its rotation, and then even more
specifically, its value at time. So value at time really
goes here on the end saying, hey, we're lookin' at this thing, more specifically, give
me its value at time. So we're putting this
little period, this decimal, this full stop and then
we're saying value at time. And then in its argument,
its parenthetical, its parenthesis, we wanna say, what time we're interested in. So what time are we talkin' about? Well zero, and zero in this
case means zero seconds. The value at time always wants you to tell it a time in seconds. For all of these followers,
all of these little things we've got arrayed around, we've
just chosen different times. So we've chosen time five,
four, three, two, one. So at zero seconds, it was here. And then at one second
this value's gonna be here. Okay, that makes sense,
we can visually see that. Two seconds, oh yeah,
it's pointing at the one that we've asked to have
the value at time two. And so on around like that. So, if we were to change what the value is here at zero seconds,
everything is going to adjust because it's at a different value at one, two, three, four and five seconds. Similarly, right now we're
looking at linear key frames. If I easy ease them, by hitting F9, notice these go to new
locations because at one second, thanks to this easing, this
is the location it goes to. So, when we're thinking
about the value at time, just remember, if you change
anything about that property, then everything else is
going to adjust accordingly because we're looking at the value of that thing at a certain time. One of the most common
ways we make use of this is to create a trail of layers. So, here we go, here's
a nice little example. Wee, we've got this
arrow that goes around, and then we have this trail
that comes out behind it. So, we've done a few extra things here. So let's talk about how
the expression changes how we manipulate it in order
to make a trail of layers. I'm gonna remove a bunch of these, 'cause they're not really
important right now, but we have a leader
and we have a follower. So the leader, we're really
just changing its position. So the position is just goin'
along, havin' a good time. Going from here to there to
there to here, good for it. And we've gone ahead and
gone Layer, Transform, Auto Orient and we have it
orienting along the path, so it's turning, havin' a good time, it's flowin' along, nice. So if we wanted to put a
trail of things behind this, we might say, oh I know, I'll just add the echo effect on here,
right, we could do that. You could stick an echo
effect on and tweak the number of echoes and you'll end up
with a bunch of triangles. But instead, you might
say, well, I wanna trail of different colored triangles, or I want a trail of hexagons, or I want a trail of circles
or something, who knows? Who knows what you need? Here's how you might accomplish that. And I say might because there's many ways to write this out or to
arrive at the same thing using expressions or using any methods in After Effects really,
but here's one way. We take our follower, and our followers, maybe they're always gonna
be underneath of each other and they're always gonna
be under the leader. So, I've gone ahead and
written P, a variable named P. And you can write var,
variable P if you like, is equal to this comp.layer,
and inside our parenthesis, our argument for the layer, we're saying, look at index minus one,
meaning look at the layer that is index three, 'cause
that's whenever we write index, the index of this current layer. Index minus one, which would
mean not three, but two or the layer that's always above. So index minus one is always, hey what's the layer above me doin'? So look at that, look at its transform. Look at its position and that's
the end of that variable. So P is equal to the
position of the layer above. Let's make another variable. And the other variable
is gonna be called D. D for maybe, displacement perhaps? Or delay, and D is equal to
this comp.layer adjustment layer so we're lookin' up here,
and then the effect called slider control and then
we're lookin' at the slider of the slider control, which
in this case is set to five. And then we're gonna
multiply that by this comp, so we're lookin' at this comp
again, dot frame duration. Frame duration is how long
each frame lasts in seconds. Variable D is basically five
times the duration of a frame, which is five frames. If this is one, then we're
looking at the duration of one frame, which is great
because the value at time would like us to tell
it a time in seconds. Which is why we're making
that frame duration change. So our final line is P, which
is looking at this position, dot value at time, so we're
looking at value at time of that position, and then what time, what time are we looking at? Well, we're looking at
time, which is gonna display whatever time the play head is, so right here time is two minus D, and D is five frames worth of seconds. So, this is at the position
that the leader was at five frames ago and that is always true. So it's always lagging
behind by five frames. So if I were to adjust this
slider here to like a one, now it's only one frame behind. And because we've set it up
that it's always referencing the layers above it, I can
go ahead and go duplicate, do, do, do, do, do, do,
duplicate a bunch of these, all of them, each layer is
referencing the layer above it. So, then if I go ahead and
increase this a little bit, you can see that we're
able to make the tail longer, shorter, more spread out, less spread out as we like. So we could have the tail grow
from being no tail at all, as this thing kind of stretches out, then we arrive at a five
and then it's gonna, maybe it's gonna pack
itself back up, whoop. And it should pack
itself up by here, boom. So we could do that kind of thing. Since we're now able to
introduce little key frames into how much of that tail,
that's because we're packing all of this stuff into that
value at time argument. So, if you want a delay of some kind, that time, the value at time needs to be time minus something and in this case, we've linked up that
something to a slider control, so we have a little
bit of control over it. If you're gonna make multiple
incidences of something, you're gonna wanna link these
properties and variables into slider controls so
you can control all of them with one slider instead of havin' to go in and manually change
each of the incidences. But that's how we might make a tail. There's another way we might do it, because right now all of these layers are referencing the one above each other. Which is okay, but like
I said, you can rewrite just about anything in After Effects to look at things a
little bit differently. So, you could make all of the
followers look at the leader, so instead of referencing each other, they reference only back to the leader. So P is equal to that,
and then we just slip in this little bit in here. So instead, the delay is getting shifted in accordance with what
index value the layers have. So it's just another
way of basically writing the exact same thing. Expressions are a little
bit like any language. There are multiple ways
to say the same thing. Some are more verbose than
others, some take more lines and some can be a lot more efficient. You can often say the same
thing with fewer words and the same is true with expressions. So let's look at one more
example to hopefully, cement the value at time for you. So here we have a null object. We're just movin' its position all around. It's going in this fun little path. Wee, it's goin' up here,
around there, good for it. We've written on these
circles, this expression. P equals position of that null, awesome. And then X is equal to, and we're looking at a slider control again. And each of these layers has
a little slider control on it. And so, let's say we set
this to like 50, all right? So the slider is set to 50%
and we're using the linear expression, we've talked
about the linear expression on this channel before,
but we'll say it here. The linear remaps things, it
remaps things in a linear way. So we're basically, taking the
value of that slider control and we're remapping the value zero to 100 into the value zero to four. Now why would we do that? Well, the animation of the
null takes four seconds, zero to four seconds, so I can
now use this slider control to describe what
percentage along this path I want it to be at,
which can be a good time, especially if I know this
might actually end up changing. So if I start altering this path, you'll notice all of the circles
are changing their position based on where this path goes. So if you have comps that
need to be hangin' out along the path of like a
rocket ship or something, or if this is like a video game thing and it needs to Pac-Man,
eat up all these circles, well you can have them hang
out always on this path. They will always be along
the path of this thing. And that keeps it all controlled, so you don't have to
manually stick key frames on all of these things,
you can use an expression to force them to always
be along that path. Now, we've been using this
on rotation, on position, you can use value at time on any property. Any property at all. For a little bit of extra
fun, try applying it to the time remap
property of a composition. And it's fun to kind of delay
animation using this method. Anyway, I think I've taken up
enough of your valuable time. Hopefully this gets you started using the value at time expression. If you like learning about After Effects, motion design, expressions, please subscribe to this channel. It's the kind of thing we
talk about around here. Try to get a tutorial up every week. Make sure you subscribe
and turn on notifications to find out when, slash if that happens. If you have questions about
the value at time expression, or any expression really, please
let me know in the comments or reach out to me on
Twitter @ecabrams on there. Or get in touch on the Facebook group, links to all that in the description. If you wanna get your
hands on the project file that we just worked on, if
you wanna see these examples and play around with them and
understand what's goin' on, head on over to evanabrams.com. Links to that file are in
the description in the cards. Go check that out, it's
available at pay-what-you-like pricing, every little bit
helps keeps the channel going. And that is pretty much it. Thank you so much for following along and if you subscribe to the channel, I'll see you around the internet.