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

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]


Code help - number counter by incremental rate

$
0
0

Hey there,

 

I've creating a number counter that counts up from 0 to 24,776 using point control that includes commas. I researched existing codes and found the one below one using this link. Here is my existing code for the source text expression:

v = effect ("Point Control")("Point");

s = "" + Math.round(v[0]);

 

if (s.length > 3 && s.length < 7)

s.substr(0, s.length -3) + "," + s.substr(-3)

 

else if (s.length >= 7 && s.length < 10)

s.substr(0, s.length -6) + "," + s.substr(-6, 3)  +"," + s.substr(-3)

 

else if (s.length >= 10 && s.length < 13)

s.substr(0, s.length -9) + "," + s.substr(-9, 3) + "," + s.substr(-6, 3)  +"," + s.substr(-3)

 

Now, I'd like to alter the code so I can change what increment the numbers grow by. Can someone build that code and explain it?

Randomly rotate layer in specific increments

$
0
0

The random(x) expression is simple enough to randomly rotate a layer to any angle, but what if I want that angle to be to the nearest 45 degrees? So my layer would randomly rotate to any of the following angles: 0, 45, 90, 135, 180, 225, 270, 315, or 360 degrees.  Thanks, Jim

Expression error using checkbox control

$
0
0

I'm trying, for the first time, to create an expression that controls a value depending on whether or not a keyed checkbox is on.  This is my code.

 


x = comp("overlay grain").layer("frame").transform.position;

 

If (effect("Frame Stutter")("Checkbox") == true)
{
    value = x + wiggle(25,5);
}
Else
{
    value = value + wiggle(25,5);
}

 


When I run this, I get the error:

 


After Effects warning: Function If is undefined
Expression disabled.

 

Error occurred at line 3.
Comp: 'main'
Layer: 1 ('Date Stamp')
Property: 'Position'

 


I have been racking my brain over what the problem is.  I have used If/Else statements in the past successfully and I know that there is just something very simple that I am missing.  I have also tried using "== 1" instead of "== true", but I got the same result.

 

Help please.

Snappier Wiggle?

$
0
0

How would you make a wiggle expression that radically reduced the time between values?  Like Wiggle that uses Exponential interpolation as inbetween values? So even though the pace would be something like wiggle(1,50), it would take much less than the 1 second wiggle interval to change between values.

 

Kind of like how a hummingbird feeds? It hovers, hovers, hovers... then snap into a new position.... hover, hover, hover... snap into new position.

 

Any ideas about this?

 

(Also, is the Jagged/Smooth option of the ancient Wiggler available in expression form?)

Noob Question: Move a layer in the opposite direction of a different animated layer

$
0
0

So say that I have an icon that I animate on the Y-axis +40px, but instead of trying to hand key the other layer each time, is there an expression I can write to have the other layer move in the opposite Y direction the same amount of units (ex: -40px)?

 

Thanks!

clamp a wiggle expression

$
0
0

How do I go about clamping a wiggle expression?

 

I am using the mosaic effect with a wiggle expression on it. The only thing is that I never want the number to become 1, only 2 or higher as with 1 the mosaic effect make vertical lines that I don't want.

 

Cheers

Problem with sampleImage in After Effects CC 2015 (Extendscript / Expressions)

$
0
0

I'm having a weird problem with a script that adds and utilises an expression containing sampleImage.

 

The script is meant to add a 'Color Control' to the selected layer, sample a particular pixel RGBA value, and use that value.

 

I'm testing this with a pure red solid.

 

Here is the script in a basic form:

 

var myComp = app.project.activeItem;

var selectedLayer = myComp.selectedLayers[0];

 

var addColorControl = selectedLayer.Effects.addProperty("Color Control");

 

var expr = "sampleImage([0,0], [0.5,0.5], true, (time+0));";

addColorControl.property(1).expressionEnabled = true;

addColorControl.property(1).expression = expr;

 

var res = addColorControl(1).value;

$.writeln(addColorControl(1).value);

 

In After Effects 2014, this writes the following to the console:

 

1,0,0,1

 

Which is correct for the red solid.

 

But in After Effects 2015, the exact same script and circumstances (red solid), gives this response:

 

0,0,0,0

 

However, if after I have run the above script I then run this:

 

var myComp = app.project.activeItem;

var selectedLayer = myComp.selectedLayers[0];  

 

var getColorControl = selectedLayer.Effects.property(1);

 

$.writeln(getColorControl(1).value);

 

It prints the correct response to the console:

 

1,0,0,1

 

As I said, it works fine in the previous version of AE (2014), but not in the current version. This not working has just crippled a couple of large scripts I'm using, and it would nice to be able to use them in the latest version.

 

Anyone have any ideas about this?


how to edit keyframe values through expressions using global values

$
0
0

hello,

 

I would like to make the values of keyframes dependent on "point controls" that I generated.

 

Is it possible to give values of the point controls to a specific keyframe?

 

different point control values would change different keyframes of the same parameter and same layer.

 

thank you!

erg

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

inertial bounce expression

$
0
0

hello everyone i have after effects cc and windows 8.

 

when i was on ae cs6 i used this expression and it worked perfectly

 

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);

amp = 5;

freq = 1.0;

decay = 5.0;

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

}else{

value;

}

 

now on ae cc it works for 1 minute and then this error pops up:    (in this case i applied the expression on the position of a null object with linear velocity)

 

 

After Effects warning: an expression was disabled as a result of an error.

 

Error at line 19 'Position' of layer 2 ('Null 7') in comp 'Comp 4'.

invalid numeric result (divide by zero?)

 

 

how can i fix this error? that expression was very very helpful!

 

thx!

expressions - best practice for duplicating layers

$
0
0

Hello,

 

I have a fairly complex set of expressions on multiple layers.  These layers together make up an overall effect for a piece of footage.  For convenience I have these expression linked to a controller null object so I can control them from one place.  Now that I have it set up, I want to duplicate the group of layers (footage item, various effects, and null object controller) multiple times.  I basically have a template for a footage effect that I want to duplicate multiple times so I end up with many pieces of footage with this effect applied.  When I duplicate the group of layers, I'd love to set it up in a way that the  expression variables will now point to the duplicated controller object.  I noticed this behavior happens if the expression is a simple pick whip from one property to another.  Basically a direct connection.  But if I attempt to store this pick whip selection in a variable to be manipulated further, this functionality ceases.  So my question is, how can I create a set up that will permit me to duplicate layers and have the expressions update as if they were a simple direct pick whip from one property to another?  Is this possible?  If not, how can I better set this up to allow me to accomplish my end result?

 

Thanks!

 

-Justin

Expression-Link two check-box controls but inverted, so on/off off/on...

$
0
0

Hi, I have a checkbox control on a layer and linked the opacity to it so off = 0% and on = 100%, I've done the same on different layer, however I now want to link that checkbox to the original layers' checkbox and invert it so if one layer is switched on, the other is off, and vice-versa. What expression do I need to apply to the second layers' checkbox control?

After Effects Combine x2 Expressions - Bounce & loopOut

$
0
0

I'm after help combining x2 expressions. A bounce expression like below...

 

n = 0;

if (numKeys > 0){

n = nearestKey(time).index;

loopOut("cycle");

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);

amp = .05;

freq = 4.0;

decay = 2.0;

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

}else{

value;

}

 

...with the standard loopOut("cycle") expression. I have a few key frames to lift an object slowly then to drop it quickly (hopefully with a bounce) and I need to repeat this indefinitely. Can any one help?

Random Number per comp

$
0
0

Hi,

 

I have a comp with a random number being generated,

 

This is what I have on the rotation keyframe:

 

seedRandom(index,true);

myValue = random(50) ;

time*myValue;

 

When i duplicate this comp, they all produce the same results.

 

Is it possible for each comp to generate it's own random number?

 

Thanks


After Effects Font Expression

$
0
0

Dear AE expressionators,

 

Concrete: I am making a template whereas the user can change the text font and that it will automatically update this to the hole template.

 

For example, see the picture.

So everything I change in the above text layer the under text layer transforms with it. But if I change the font it doesn't.

Does after effects use a different expression for automatically changing a font?

 

I would really appreciate your help!!!

 

I'm using after effects CS6

After Effects Expressions

$
0
0

Hey. I'm looking for a solution to an issue I have... And I don't know any javascript, so I can't find it. Can you help me, please?   So tell me if this is possible. Variable "a" equals "time", while variable "b" reaches value 100. And "time" is a constant number. In other words, simply find value of "time" when "b=100" and then assign this value to "a".

After Effects Universal Expressions

$
0
0

1. What are universal expressions?

  • I want examples of applications of universal expressions and how to identify non-universal expressions.


  • When my project use non-universal expressions, I can use a plugin called "ExpressionUniversalizer 2" to support all languages.

2. But there's another way to get the result of transforming the non-universal expressions in universal without use the plugin?

 

Please provide me all possible details.

 

I need to create a template that uses expressions and need that the template supports all languages.

 

Thanks!

wiggle between parameters

$
0
0

I want to wiggle between 2 values. So that my glow stays bright enough to see and still flickers.

 

why would this not work?

 

x= (50-75)

wiggle(4,x)

Expression help with time remapping

$
0
0

Hi

 

I have a 25fps Precomp with an animation that changes on every frame.

 

In the master comp I want to apply an expression to its time remap property so that it holds on each consecutive frame for a given duration, eg on Frame 1-15 we see frame 1 of precomp, on frame 16-30 we see frame 2, and so on.  I can't figure this out. Tried posterizeTime and some other bits to no avail and can't find it elsewhere on the web.

 

Thanks, Steve

Viewing all 47983 articles
Browse latest View live


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