Quantcast
Channel: Adobe Community : Popular Discussions - After Effects Expressions
Viewing all 47983 articles
Browse latest View live

AE: Expressions - Animate position change of each layer from top to bottom?

$
0
0

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) TREASURESALE VALUE
(PC2) Earth Gemstone1500
(PC3) Beautiful Bottle120
(PC4) Strong Bone200
(PC5) Rough Scales250


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


Random scale with equal values for xScale and yScale

$
0
0

Hi there,

 

professional scripters might not think of this to be a problem, but I cannot solve it on my own after hours of trying.

 

I found a random script on www.motionscript.com (thank you so much Dan, for this great resource, you're awesome!).

 

The sample for "random motion - more chaotic" is exactly what I need, but for the scale property with same random values for xScale and yScale (so that the random scaling is proportionally). I cannot figure out how to do this. I know I need another variable, but I don't know where.

 

Actually, I want to have a matrix of dots, each scaling up and down again randomly and independently in size and timing...

 

This is what I got so far:

 

segMin = .3;
segMax = .7;

minValX = 100;
maxValX = 200;
minValY = minValX;
maxValY = maxValX;

minVal = [minValX, minValY];
maxVal = [maxValX, maxValY];

seedRandom (index, true);
segDur = random (segMin, segMax);
seed = Math.floor (time / segDur);
segStart = seed * segDur;
seedRandom (seed, true);
startVal = random (minVal, maxVal);
seedRandom (seed+1, true);
endVal = random (minVal, maxVal);
easeOut (time, segStart, segStart + segDur, startVal, endVal);

 

I'd appreciate someone's help without being to demanding :-)

 

Thanks a lot for reading this.

 

Chris

Time Remap with expression slider not frame accurate

$
0
0

Hi all, first of, I hope this hasn't been posted before - I couldn't find anything on this specific issue.

 

I have a simple mockup character rig with 3 compositions.

01_Character is where all the controls would be.

02_Head is the head subcomp.

03_Eyes is for the different eye states. It's only 3 frames long and on each frame is a layer containing a different eye.

 

In 01_Character is a null object with a slider control. This will be used to switch between different eye states. 02_Head has been added to 01_Character as a layer.

03_Eyes has been added to 02_Head as a layer. This 02_Head layer has Time Remap activated. There is an expression on the time remap:

 

control = comp("01_Character").layer("Control").effect("Numbers")(1);
framesToTime (control -1)

 

Now when I animate the slider in 01_Character comp the eye states (in my mockup numbers) appear and disappear as planned. However this only seems to work while the values increase. As soon as I animate decreasing values the number-states always switch one frame too soon.

That's only when I animate the switches with hold keyframes. When I animate with linear keyframes, the highest value - which should appear for one frame - doesn't appear at all, even though the animation curve shows the correct values.

 

In this screenshot the curve shows value "3", however eye #2 is rendered.

 

Here the animation curve shows the value "3" but #2 is rendered instead.

 

Any ideas on why that's happening? I have played around with different Math.floor and Math.round functions, but I can't seem to resolve this.

Or do you have any alternative ideas for switching asset states? I could put expressions on each layers' opacity, but that has an impact on the rig's performance if I have e.g. 5 x 2 eyes. 5x2 eyebrows, 20 mouths, 20x2 hands, etc. each with their own opacity expression.

 

Cheers, Michael

Expression for image replacement depending on text layer text.

$
0
0

Hello, i wanted to ask is it possible to replace image in composition depending on text layer text. I.E. text layer contains code ##34 and expression tells what kind of image should be placed depending on if conditions in image expression.

Sincerely, Deimantas

How to delay an animation

$
0
0

Sorry for my bad english: i'll try to be clear.

Once a layer has some animation (position, scale etc),

how can i link another layer to this first one (or the animated property of the first one to the another equivalent one)

and make the second layer animation delay some number of frames?

 

Another situation:

same start point above, but, after duplicate that layer,

how to delay the animation time some frames?

 

Thanks for the attention

offset corner pin with different x y offset values

$
0
0

Hello!

 

Suppose you have a keyframed corner pin effect. Is there a way to extend a pin point (example: top left corner point) with different offset values for X and Y using expressions?

I tried everything, but I can't get it to work: the extended point doesn't stick with the right proportion over the animation.

This expression is one of the many i applied without any success. It works only if offset X and Y values are equal (ex.

Any suggestion? Thanks.

 

 

// CALCULATE CENTER COORDINATES

TL = effect("Pin")(1);

TR = effect("Pin")(2);

DL= effect("Pin")(3);

DR = effect("Pin")(4);

var vertices_x = [];

var vertices_y = [];

var min_x = Math.min(TL[0],TR[0],DL[0],DR[0]);

var max_x = Math.max(TL[0],TR[0],DL[0],DR[0]);

var min_y = Math.min(TL[1],TR[1],DL[1],DR[1]);

var max_y = Math.max(TL[1],TR[1],DL[1],DR[1]);

var mid_x = (min_x + max_x) / 2;

var mid_y = (min_y + max_y) / 2;

center = [mid_x,mid_y];

 

// OFFSET

offset = [20,50];

 

// TOP LEFT VECTOR

vector = normalize(TL - center);

 

// CALCULATE NEW TOP LEFT

x = TL[0] + * vector[0] * offset[0];

y = TL[1] + * vector[1] * offset[1];

[x,y]

Storing a position value from the previous frame

$
0
0

Hey guys,

 

So, I'm trying to assign the X value a null object had at the previous frame so I can continue to subtract a number from it cumulatively. I'm trying to assign it to a variable (prevframe). I'm not sure where I'm going wrong, but the line I'm trying to do it on is written as follows:

 

prevframe = transform.xPosition.valueAtTime(time-(1/24))

 

So in my mind, this should be taking a look at the value of X on the null, then looking back in time to figure out what it's value was on the previous frame (my frame rate is 24, so I'm dividing 1 second in to 24 pieces and telling it to subtract that much from the current time), and assigning whatever that returns to the variable. But it's just returning a static value, even though I'm subtracting from it. I feel like it's not the correct syntax, but I really have no idea.

 

I want to continue to subtract a value which is based on the velocity of another object from this, which I have worked out, I just can't figure out how to reference what this nulls X position was in the previous frame so it always returns the same value until all motion has stopped. The formula the variable is being run through looks like:

 

finalposition = prevframe - camvelocity

 

Which is then assigned to the final X position of the null object.

 

So, I'm not sure where I'm going wrong. I hope I've provided enough information to help someone wrap their head around this and hopefully help me solve it.

 

Thanks in advance,

 

-Seth

Change text colour with an existing slider control

$
0
0

Hi guys, I am making a 9:16 (vertical) graphics template themed with the logo and colours of the 20 teams of the English Premier League.  My expressions knowledge only goes so far as wiggle and a bit of pick whipping!

 

I am trying to make an essential graphics template so that the editors can use the slider to pick the team that they want to have as their on screen graphic in Premiere (rather than having to go into AE).

 

So far I have in my essential graphics tab the four lines of text, the slider, and a comment which tells the user which team is which number. The slider goes from 1 to 23 (20 teams plus three others).

 

 

Here is what that looks like:

Screen Shot 2018-02-05 at 10.27.04 PM.jpg

I have so far been able to use the slider to change the logo (by making all other logos 0% opacity), to change the name of the team (by making all other team names 0% opacity) and to change the background colours of the boxes.

This is the expression I used to do all of this. It is in the opacity setting for each object:

 

 

slider = thisComp.layer("Team Slider").effect("Slider Control")("Slider");

 

 

if (slider == 6) 100 else 0;

 

 

My problem is that I also want to be able to change the colour of the text when the slider is changed. Does anybody have any idea of how I can do this?

 

 

Below is the project file:

 

https://www.dropbox.com/sh/0yrknu66b8fjvcg/AADNJFMAoNLRlT7INQ1yh9rla?dl=0

 

Thank you!

 

David.


How do I generate and hold random frames (for .5 seconds) when applying expression to time-remap

$
0
0

Hi guys,

 

I have the following expression on a time-remapped layer made up of 5 frames:

 

 

nFrames = 5;

seedRandom(index,true);

n = Math.floor(random(nFrames));

f = timeToFrames();

for (i = 0; i < f; i++){

  n += 1 +Math.floor(random(nFrames-1));

  n %= nFrames;

}

 

 

framesToTime(n);

 

The frames are changing pretty fast and I'm wondering which part of this to modify to get them to hold for half a second.

 

Thanks for any help!

Start/Stop Time Expression

$
0
0

Hi,

 

I'm new to expressions and I need to start and stop the expression at specific frames.

 

My expression as follows:

 

f = effect("Frequency")(1);

p = effect("Period")(1);

Math.cos(p * textIndex/textTotal + time*f)*50

 

Thanks in advance for all your help!

Unterminated String Constant...

$
0
0

I'm trying to create an expression for the X position of a layer containing an image that hooks it to a slider control in a Null.

I keep getting an "Unterminated String Constant" error for anything that uses a name.

 

thisComp.layer("Carousel Controls").effect("Slider Control")("Slider"); —Gives the error

thisComp.layer(1).effect("Slider Control")("Slider"); —Works, but isn't preferable

 

If I change the name of the slider control to Expand:

thisComp.layer(1).effect("Expand")("Slider"); —Gives the error

 

I've done this in the past and it's a pretty straightforward thing I'm attempting.

Help Combining two expressions

$
0
0

Hi everyone.  I have two expressions which im trying to combine to work on the scale property of a shape layer. The first one is a bounce expression and the second is an expression to use a slider to control the scale of a layer (on the second keyframe). It might help to check out the original thread (Controlling the scale of a shape layer using slider control and expressions. ) where I was given the second expression to get an better idea. If anyone can help that would be greatly appreciated.

 

 

Bounce expression

 

amp = .1;

freq = 2.0;

decay = 4.0;

 

n = 0;

if (numKeys > 0){

n = nearestKey(time).index;

if (key(n).time > time){

n--;

}}

 

if (n == 0){ t = 0;

}else{

t = time - key(n).time;

}

 

if (n > 0){

v = velocityAtTime(key(n).time - thisComp.frameDuration/10);

value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);

}else{value}

 

 

Expression to control scale of the layer

 

x2 = thisComp.layer("Null 1").effect("Slider Control")("Slider");

x = ease(time,key(1).time,key(2).time,key(1).value[0],x2);

[x,x]

Measuring length of a curved path shape ?

$
0
0

Is it possible to measure the length of a curved shape (path) in after effects?

 

Illustrator has a built-in ability to measure stroke (curve lengths) so it seems like AE should have something similar.

Slider only scale X

$
0
0

Hi I got a slidercontrol = xScale

and a shape named = BAR

 

What expression would only scale the X

 

Regards

Flemming

Rectangle path expression

$
0
0

Hi,

I want the path of Rectangle 2 to copy the path of Rectangle 1, only to be 30px smaller on each axis.

For some reason it's only shortening the path by 30px on the x-axis.

Any ideas how I can get it to shorten on the y-axis as well?

 

The reason I'm doing it is so I can adjust the size of one rectangle rather than them both.

 

Thanks,

Ryan

 

Screen Shot 2017-06-11 at 20.35.39.png


move from one random position to another?

$
0
0

Hi,

this is probably simple for someone who knows how to write expressions better then I do. (I hardly do).

 

I want a Textobject to move from one keyframe to another. Both keyframes should get a random value. (first keyframe-Position somewhere in the upper part of the comp; second key-position somewhere in the lower part of the komp).


Please help. Thanks!

AE 2018 Math function

$
0
0

Hi All,

 

Appreciate some help for a newbie.

 

I am using the text slider function on Comp 1.

in the source text I have the expression effect("Slider Control")("Slider").value.toFixed(0,)

 

this works no problem.

What I am trying to do is have the number displayed only increase in increments of 10. so example if its 15 then its 20 but if its 14 its 10.

 

I have found many expressions, however I cannot make any work, either I'm using the wrong syntax or the wrong location.

 

Appreciate if someone can tell me exactly where the expression is put and what it says.

 

thanks

Multiple Expression To One Property

$
0
0

Hi everyone,

 

I have wiggle expression on rotation property of the layer with keyframes. I also want to add master Dan Ebberts' pendulum expression on the same property. Is this possible? I tried if else statement with checkbox (if checkbox =true do wiggle thing else do pendulum) but gave me error message "cannot assign value because it is read only". By the way this layer is Duik's controller and parented to zero object. Is there a way to do it?

 

Thanks.

Expression to duplicate whole layer several times.

$
0
0

Hi everyone,

 

I am pretty new with AE, I want to ask if there is an expression, which would let me duplicate selected layer?

I want to use expression, because I have to use like, 30 layers of same object, only with some position and rotation offsets.

 

THank you.

Time expression : slow down, then stop

$
0
0

Hi everyone,

 

I've been looking for a solution for hours and I couldn't find any. Basically, I'm using this expression to make a layer rotate :

 

timeToStart = 4;

timeToStop = 14.60;

if ((time > timeToStart) && (time < timeToStop))

{

  time*400;

}

else

{

  value;

}

 

I would like the speed to decrease a little before the layer stops, so that the motion looks more natural. Does anybody know how I could do this?

 

Thanks a lot !

Viewing all 47983 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>