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

Is it possible to confine expressions to specific keyframes?

$
0
0

I am definitely a beginner when it comes to expressions.

I am currently using a "bounce" expression on the position parameter of some objects as they come on screen. However, the next time they change positions, I don't want them to bounce. Every time a motion tween ends in a static position, the position expression gets applied and the stuff is moving around.

I'd like to be able to keyframe the expression so that it worked only when on the keyframes that it makes sense to affect.

 

amp = .05;

freq = 1;

decay = 7;


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

}

 

I got this script from somewhere online. The only thing I know how to manipulate are the initial values of amp, freq, and decay.


Set inPoint with expression?

$
0
0

Hi,

 

Is there some way to set the in and out points of a layer in an expression?

 

thisLayer.inPoint seems to be read-only...

 

Thanks,

 

S

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!

Wiggle expression - slider control

$
0
0

Hi all

 

I had a solve for this from Dan Ebberts but I seem to have lost that content in the Jive update. I want to use a slider control for a wiggle, but when I have my basic wiggle expression applied to position, then pick whip from that to the slider, I get the below expression.

 

temp = effect("Wiggle Control Sliders")("Slider");

[temp, temp]

 

What is the fix for this/ way to do it right?

 

At the minute I'm using the expression below instead, but I hate not knowing the right way to do something! Using sliders/ creating decay in expressions has always been an issue for me...

 

wiggle(15,effect("Slider control")("Slider"))

 

Any help would be appreciated

 

Thanks!

Expression Get Project Path or Name

$
0
0

Hi,

 

I am new to After Effects as in I have just seen it for the first time today!

 

What I'd like to know is, is it possible to write an expression to return either the current project name or file path?

 

I'm assuming no as I cannot find any reference to this in the language reference. How would I go about integrating a script with the project to return the project name?

 

I have tried something basic like:

 

Expression code:

 

var currpath = $.evalFile(filepath);

 

filepath is the path to my script file, the script is like the below:

 

GetPath()

 

function GetPath() {

 

return app.project.name;

}

 

With this I get an error similar to method name 'Global' not found - not at my work computer so can't remember the exact message.

 

Any help would be appreciated.

 

Thanks,

 

Mark

Re-using expression-generated values to input into other expressions (read-out)

$
0
0

Hi there everyone. I was wondering if there is a way to 'capture' expression generated values and either buffer these values or re-using them directly in other expressions. I am trying to track rotations of parented layers, which are generated from the DuDuf IK expressions. Getting the rotation through a pick-whip will always return zero, of course; but as After Effects is able to physically show the expression generated value as a number, I guess it should also be able to output this number somewhere as a (buffered) digital value to be re-used somewhere again.

 

Anyone ideas?

Sway 3D object on Z-axis using slider?

$
0
0

Hi there,

I have multiple objects (side by side) which I would like to sway on the z-axis as if the wind is blowing them.  I already have their anchor points at the top of each object.  I have a few issues:

  1. I have multiple objest which I would like to have random movement on.  I don't want ALL objest to sway to the left, then ALL sway to the right.  Rather I would like them to be somewhat random/organic.
  2. I need to be able to control all of them with a slider...  I would like to be able to turn the sway up and down and ultimately have them all come to rest at a still position (with 0 z-rotation).
  3. A slider would be ideal as I would like them to gradually stop swaying, not just "on" and "off"
  4. There are about 15 objects to sway.  If there is no way to randomize them I would be happy even to make multiple slider controls so that object 1, 4, 6, etc. would be controlled (and have identical movement) by 1 slider, then objects 2,5,7 etc. would be controlled by another, and so on.  I suppose this would simulate randomeness but would not be ideal.  I would like the slider conrol to be dead simple.

Any thoughts?

Thank you very much!

-Stephen

3D Corner Pin w/ Precomps

$
0
0

Hi everyone,

 

I've been using Dan's expression for getting the corner pin in 3D. But it's getting tough with the following setup:

 

  1. Main Comp
    1. Camera
    2. Precomp
      1. Camera (pick whipped position and POI with main comp camera and with the same settings)
      2. 3D Null
      3. 3D Null
      4. 3D Null
      5. 3D Null
      6. Solid w/ Corner Pin (using Dan's expression w/ nulls)

 

It all works perfect when:

  1. Both the main comp and precomp are of the same dimension
  2. The precomp's position stays centered

 

Now I can simply fix the first by calculating the offset and adding this to the expression, but the second is the problem. The calculation doesn't work, because of z-space. And by offsetting the toComp (toComp( [0,0,1500] )) it's hard to get right and leaves an apparent offset.


Any ideas for getting it spot on?


Animate a Blur Letter-by-Letter

$
0
0

So I've just learned about creating an expression selector, but I know absolutely nothing about writing code for expressions. What I want to achieve is this: I have a paragraph of text filling the screen; it begins all blurred and then unblurs one letter at a time until it reaches the end of the text.

 

I have the text layer, then I have the blur animation keyframed from (50, 50) to (0, 0) 5 seconds later. By just putting on an expression selector, I seem darned near what I need but the animation doesn't start with letter 1 blurred, it has already set the blur on character 1 to 0, progressing to blur of 50 on the last character. I need all of the characters to start at blur 50 and then start the animation from character 1.

 

The default expression for expression selector is "selectorValue * textIndex/textTotal." I believe I need some kind of offset so that it doesn't start the animation at the beginning of my composition. I'm not sure how to code that or even how to look up the code, though I'm pretty sure it's something ridiculously simple.

 

The next issue is I'd like the letters to go from 50 blur to 0 blur one at a time in the span of a fraction of a second. Is this asking for a lot of code? I looked at a tutorial covering this and it seems like a lot of code may be involved in that and maybe I'm out of my depth. I don't even know how to go about learning what code is needed for this.

 

Thanks for any help. I hope this is clear.

Increasing opacity level after audio keyframe animation

$
0
0

Hello all.

 

AE Newb here. I'm just getting my feet wet with this program.

 

Currently I'm animating the opacity of an object by the keyframes (generated via Convert Audio to Keyframes) via the pick whip. I'm getting the results I'd expect, but the net effect is too dark. It's as if I'm looking for a slider labeled "overall level" that I could turn up, or a "min / max " setting that would allow me to tweak it up a notch. I hope I'm describing this clearly enough. Is there a way to grab all the little keyframes and increase their value?

 

Again, I'm getting the right type of pulsing to the audio, just not bright enough. Any suggestions?

 

Many thanks!

 

Mark

Looping a random section of a layer

$
0
0

Hey guys, I'm trying to write an expression and am a bit out of my depth.  In short, I'm basically trying to replicate the function of the "Random - Split Clip" function in Particular if you're familiar, but just for a single layer.

 

In more detail:  I'm trying to write an expression to be applied to the time remap property of a comp.  This comp would be composed of a series of video clips, all exactly the same length.  The input parameters would be a random seed, and the length of a single clip.  The end result would be that the layer would loop a single clip in the series, chosen at random.  If the layer were duplicated, each instance would play a different clip.

 

Any thoughts about how to accomplish this?  Thanks in advance for any help!

 

 

Extra credit:  Could I make this work even with clips that were uneven lengths?  Perhaps by using layer markers or something?  What about a version with an additional parameter for loop type (ping-pong etc).

Add a 0 in front of a number

$
0
0

Hello,

 

I am using a simple expression to make a calendar, going from 1 to 31

Until the number 10 i would like to display a 0 in front of the number.

Unfortunately everything I am trying doesn't work.

 

Here is the expression:

 

v=time/thisComp.frameDuration;

t = (v%31)+1;

if (t >0 && t < 10){

value=""+"0"+t;

}else{

value=t;}

 

I am on AE CC with Mac maverick.

 

Thanks

NIco

Pendulmum expression by Dan Ebberts

$
0
0

There is this rotation expression created by Dan Ebberts for a pendulum swing that I was wondering if it is possible modify and have it begin at a specific time on the timeline

 

veloc = 12;

amplitude = 40;

decay = 1;

 

amplitude*Math.sin(veloc*time)/Math.exp(decay*time)

 

Thanks for any help on this.

 

Ira

trapezoidal wave in AE

$
0
0

trying to figure out an expression for a trapezoidal wave function in AE.  I have not found any forms that discussed this wave formation.  I am pretty new to AE's expressions.

AE CC 2014 - Wiggle Expression not assigning similar values on scale

$
0
0

So I've just noticed that the wiggle expression no longer works how it used to. I found a released article explaining changes in the Noise Algorithm used for the wiggle expression what’s new and changed in the 2014 update to After Effects CC  |  After Effects region of interest and am referring to the "fixed bug in implementation of Perlin noise algorithm" section.

 

I'm not sure if this is what's causing the issue but let me explain.

 

I'm just adding a wiggle expression on to an object's scale.

wiggle(5,50);

 

This would normally scale the object's parameters with the same value. so it would be (100,100) to (125,125) and so on.

Now however with CC2014 the expression is assigning different values to each value so getting (125, 115) or something even if the 'constrain proportions' button is enabled.

 

So I tried to trick it:

 

temp=wiggle(5,50);

[temp[0],temp[1]];

 

Still got different values even though i'm telling it to insert the same variable?

 

temp=wiggle(5,50);

temp;

 

Still got different values... I don't get it can anyone help?


What benefit should I get from "// cacheCompareSamplesPerSecond 0"?

$
0
0

Background for anyone reading this: http://blogs.adobe.com/aftereffects/2014/04/new-changed-after-effects-cc-2014.html I think I must have misunderstood what this statement does for an expression.  I was hoping "// cacheCompareSamplesPerSecond 0" would allow me to force AE to evaluate an expression only once, on the first frame of the comp, but clearly it isn't that simple.  I've applied it to a number of expressions, each of which is designed to evaluate to one value for the entire comp, but I'm not seeing any improvement in render times. What am I missing? This is on Mac AE CC 2014 (13.1).

Tracking puppet pin tool with null object track(HELP)

$
0
0

I'm trying to track my puppet pin tool to a null object.

 

I am using the code

 

n=thisComp.layer("NullObject_Name");
nullpos=n.toComp(anchorPoint);
fromComp(nullpos);

 

But ever time I assign the name of the null obect tp the puppet pin (eg. hair_bottom_left0)

 

n=thisComp.layer("hair_bottom_left0");
nullpos=n.toComp(anchorPoint);
fromComp(nullpos);

 

The pin tracks a different position and not the null object.

 

How do I get the pin to track to the null object I assigned it too?

Control Layer in point of expression % Number Count

$
0
0

I have an expression that Dan  Ebberts created for number counting with a percentage sign

 

beginCount = 0;
stopCount = 100;

 

beginTime = 0; // start counting at time = 0
countDur = 4; // count for 4 seconds

 

"" + Math.round(linear(time,beginTime,beginTime + countDur,beginCount,stopCount)) + "%"

 

For my animation the layer starts around 16 seconds into my timeline and the expression has already finished before then.  Is there a way to control the
in point for a layer for this expression?

 

Thanks very much

 

Ira

Very basic Radial Wipe / Opacity expression

$
0
0

Hey Guys

 

Sorry for asking what is probably a super elementary question. Why doesn't my simple expression below achieve the result of dropping the opacity by 25 for each quarter of completion? Am I missing something basic? Instead it stays at 100% until the final quater where it drops to 25. Im pretty fresh at expressions so hope sorry if such a function is written wrong.

 

Cheers

 

EXPRESSION ON OPACITY

trans=effect("Radial Wipe")("Transition Completion");

 

if (trans<=75 && trans>50){

75}

if (trans<=50 && trans>25){

50}

if (trans<=25 && trans>0){

25} else {100};

Help with After Effects' expressions

$
0
0

Hi, I'm actually working on simulations of movements and I'd like to make an expression to set position and rotation in function of time . my functions are :

 

position : X(t)= 15(cm/s)* t (s)

 

rotation :  F(t)= -5(rad/s) *t (s)

 

 

 

Thanks in advance

Viewing all 47983 articles
Browse latest View live


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