Copy link to clipboard
Copied
So I just started using AE this week. I'm a super newbie. Any assistance you give me is appreciated, but should also be dumbed down so I can follow it.
I'm making these dungeon tutorial videos for Final Fantasy XV and I started working on the first project.
I spent about an hour making 1 table and animating it, and I will obviously be using this same table for every dungeon tutorial, but rather than copying and pasting every layer and making new compositions and yadda yadda, I started looking into expressions today to achieve this (I'm assuming simple) effect that I'm going for.
So essentially, picture this in your brain.
The dungeon tutorial is something you'd see in a strategy guide. The first 30 seconds of the video feature: The Treasure you will find in the Dungeon, the Monsters you will fight in the Dungeon, the name of the Dungeon, the Dungeon Level, etc. And each of these things I will need to be able to customize for future dungeon tutorials, so naturally I don't want to spend 8 years editing these things keyframe by keyframe, that's just madness. I'd rather play the game.
I have 1 Composition named "Treasure Overview"
And this Composition is made up of 14 Pre-Comps.
Each Pre-Comp is basically a row in a table.
So picture the table as such:
(Pre-Comp 1) TREASURE | SALE VALUE |
---|---|
(PC2) Earth Gemstone | 1500 |
(PC3) Beautiful Bottle | 120 |
(PC4) Strong Bone | 200 |
(PC5) Rough Scales | 250 |
etc...
Each Pre-Comp is comprised of 4 layers:
- text: TREASURE
- text: SALE VALUE
- background for Treasure
- background for Sale Value
Super easy, nothing fancy
For simplicity sake, let's say that the first row of the table is at position (0,0)
That would put row 2 at (0,1)
row 3 at (0,2)
row 4 at (0,3) etc
I want to animate the rows in the table using expressions. So that the rows basically unfold vertically.
They all start at (0,0) and end up in their final position (0,1) (0,2) (0,3), etc
SO FAR, the only thing I've managed to do is create an expression on each layer so that the Y position is offset by 38 (the height of each pre-comp)
y = thisComp.layer(index-1).transform.position[1];
[0, y+38];
this sets the y value for each row in the final position that it's supposed to be in, but I can't get it to animate in succession.
I've tried looking up tutorials using valueAtTime()
and that works... but not really. I'm clearly missing something, because I can't seem to specify both the POSITION AND THE "DELAY in animation"
every time i follow these tutorials I get errors upon errors when I try to adjust the tutorials to fit what im trying to do
I need something like (pseduo-code incoming)
thisLayer.transform.position[0, y+38].valueAtTime(time + 5);
Something that will let me specify the start and end position and the delay in animation
using an expression
Rather than try to create an expression I'd create an animation preset - one for each of the rows, by simply pressing the U key for each nested comp, selecting all of the animated properties, and then selecting save animation preset. Study up on animation presets by typing animation preset in the Search Help field at the top right corner of AE and then check out the help files and the community resources.
if you really want to learn how to use expressions then you can use the index of the layer p
...Copy link to clipboard
Copied
Chicken-Egg-problem. You can't define anything in your code that doesn't exist. It's inherent in how AE evaluates the persistent property values like position before throwing the expression on top of it. That aside I see no reason why you would even bother to use an expression. You simply animate one of the table rows, copy&paste the keyframes and offset them in time. It's merely a question of adjusting the anchor points and parenting things together. I really think you are over-complicating this and regardless of this, this would also be your answer: to use valueAtTime() you actualyl have to have something to sample, meaning keyframe data. See how this is becoming a circular argument? Of course one could create a prototype layer and reference it, but as I said, it's not necessary, even more so, since temporal math can be a pain to deal with.
Mylenium
Copy link to clipboard
Copied
Rather than try to create an expression I'd create an animation preset - one for each of the rows, by simply pressing the U key for each nested comp, selecting all of the animated properties, and then selecting save animation preset. Study up on animation presets by typing animation preset in the Search Help field at the top right corner of AE and then check out the help files and the community resources.
if you really want to learn how to use expressions then you can use the index of the layer plus a multiplier to arrange layers by looking at the layer above. You can also use the layer in and out point to start a move. Things can get fairly complicated fairly quickly. For example, this expression, which is one of more than 200 that I have saved as animation presets to speed up my work, arranges layers based on the layer size and the position of the first layer. This is what it takes to simply stack up layers:
// Find Layer Size and calculate new size if scaled
sf = scale - [100, 100];
xSize = thisLayer.sourceRectAtTime().width + (thisLayer.sourceRectAtTime().width * sf[0]/100);
ySize = thisLayer.sourceRectAtTime().height + (thisLayer.sourceRectAtTime().height * sf[1]/100);
realSize = [xSize, ySize];
// Set number of columns
cn = Math.floor(thisComp.layer("DL controller").effect("numCol")("Slider"));
if (cn <= 0){
numCol = 1}
else numCol = (cn);
// Set positions
cp = thisComp.layer("DL controller").position;
sp = thisComp.layer("DL controller").effect("sp")("Slider");
if (sp == 0) {
sp = 0}
else sp = sp;
col = (thisLayer.index-1) % numCol;
row = Math.floor((thisLayer.index-1)/numCol);
pos = [cp[0] + (sp + realSize[0]) * col, cp[1] + (row * sp) + realSize[1] * row];
For this expression to work you need to name your first layer DL controller and add two sliders, one for the number of columns you want (numCol) and one for spacing (sp). You simply position the DL controller layer and add as many layers as you wish. All layers will be evenly distributed as long as they all have the same scale. I've added an expression to scale for the controller and the slave layers so if you adjust the scale of on the scale of all matches. I actually use this preset quite a lot and it would work perfectly for aligning your layers but it won't animate their position.
If you want to automate an animation the expression starts to get a lot more complicated. For example this expression looks at the layer's scale, the layer's size, the layer's resting position and the in and out points of the layer. The way you use this expression is to set your layer at it's hero position (at rest) then set an in and out point, then adjust the timing and the bounce and the speed of the move using sliders the the animation preset automatically adds to the layer's effects.
sif = effect("slideIn Frames")("Slider");
sof= effect("slideOut Frames")("Slider");
// find in and out point
inTime = sif * thisComp.frameDuration;
if (effect("Match SI SO")("Checkbox") == 0) {
outTime = sof * thisComp.frameDuration;
}
else if (effect("Match SI SO")("Checkbox") == 1) {
outTime = inTime;
}
// Fix layer size when scaled
sf = scale - [100, 100];
xSize = width + (width * sf[0]/100);
ySize = height + (height * sf[1]/100);
realSize = [xSize, ySize];
// Set Positions
spx = 0 - realSize[0] + realSize[0]/2 ;
rstx = value [0];
rsty = value[1];
epy = thisComp.height + realSize[1] - realSize[1]/2;
// create movement
freq = effect("bounce Frequency")("Slider");
amplitude = effect("bounce Amplitude")("Slider");
decay = effect("bounce Decay")("Slider");
posCos = Math.abs(Math.cos(freq*time*2*Math.PI));
nt = time-inPoint;
y = amplitude*posCos/Math.exp(decay*nt);
moveIn = Math.min(linear(time,inPoint,inPoint + inTime,spx ,rstx-y));
moveOut = Math.min(easeIn(time,outPoint - outTime,outPoint - thisComp.frameDuration,rsty ,epy));
[moveIn, moveOut]
Combine the two presets and you might have something that would work, but if it were me from the description of your workflow I'd just save an animation preset for each of the layers that make up the rows in your project and be done with it in about 5 minutes.
Copy link to clipboard
Copied
Hi Pixii,
Could you please let us know if any of these responses helped you out?
Thank you,
Kevin
Find more inspiration, events, and resources on the new Adobe Community
Explore Now