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

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!


Parenting Layer Positions - Can Variations Be Added?

$
0
0

If I parent one layer to a child layer, then the child layer will move exactly the same as the parent layer. If the parent layer moves 200 pixels to the right, then the child layer will move 200 pixels to the right.

 

Is there a way to vary the way the child layer moves? Say, a lesser percentage of pixels?

 

See below. The parent layer is the right pupil, and the child layer is the left pupil. Both pupils are centered, and look like they're in the right place.

Screen Shot 2015-01-05 at 10.45.10 PM.png

The right pupil parent layer moves to the right, and the child layer left pupil moves the same distance. It's starting to look wrong.

Screen Shot 2015-01-05 at 10.45.37 PM.png

The right pupil parent layer moves all the way to the edge of the eyeball. Now the child layer pupil has left the eye socket, and seems kind of other-worldly.

Screen Shot 2015-01-05 at 10.46.06 PM.png

 

Is there a way to tell the child layer to somehow move less than the parent layer? Say, 70% or 80% of the distance of the parent?

How to automatically "fit to comp" any imported file?

$
0
0

Hello everybody

 

i'm using a plugin to dynamically import video files into some comps i previously configured.

All these comps are 1280x720 and this plugin, when triggered, basically takes hundreds of video files i have in a specific folder on my PC and imports them in AE and puts each one of them in each comp.

For my job i sell hundreds of videos per year during sport events (all videos have the same structure). That's why i use this script, which automates my work and automatically edits each video.

 

THE PROBLEM

The video files are not the same resolution. Some are 1280x720, some others are 1920x1080.

The plugin simply imports them and puts them into the comp, which means the 1920x1080 files will not be properly scaled.

As you can imagine, i can't open each comp and right click on the video and click "fit to comp" because, having hundreds of comps each time, it would be a huge waste of time, and it would be useless to use a script.

 

THE SOLUTIONS I THOUGHT

1) Is it possible to tell AE to automatically fit to comp any video imported into a comp? (something like "default scale to frame size" of PPRO)

2) If 1 is not possible, i came up with a weird but possibly working solution. In each comp i put a null object with an expression that changes the scale of the imported video. Hence, when the video is imported, the expression on the NULL object takes care of resizing the imported video. The question is: how can i tell that expression to change the scale of a video not yet imported (i already have the code of the expression, found somewhere ont the web...i just need to tell the null object to apply the expression to a video file that is not yet imported)?

 

 

Thanks for support!

Using previous and upcoming x position keyframes to set a semi-circular path

$
0
0

I've got a little circle travelling along at a constant velocity in the x access but I want it to hit certain points as though it's bouncing from one to the other. These points are at varying distances between them.

 

What I was thinking was to set up an expression that calculates the time taken to travel between the previous keyframe in time and the next one, as well as the distance between them, to give me the bounce path between them.

 

I was thinking of a formula a bit like this:

 

[value[0], KDist*Math.abs(Math.cos(KTime)]

 

My only problem is I don't know the java script to calculate KDist (Distance between previous and upcoming keyframes) and KTime(a formula to calculate the values from the time so that Math.cos(Ktime) = 0 at the first keyframe and 0 at the end and 1 in the middle.

 

I hope that makes sense.

 

Thanks a lot.

 

John

Property links vs Relative property links

$
0
0

Now that "copy with relative property links" is available, in what case would you find using just "copy with property links" beneficial. Wouldn't the relative copy work just the same in all cases?

Possible to set Source Text from another comp?

$
0
0

Let's say there is a Comp1 with a pretty complicated animation that involves a text layer. CompMain is the main comp with 10 instances of Comp1. Each instance has different text, position and timing. Can I set the Comp1 text layer Source Text from an expression in CompMain? If this is not possible, is there any workaround? Otherwise, the alternative would be to have 10 versions of Comp1 with different text and that would be too messy.

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!

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


Error in line 11 AE Inertial Bounce (Created by Dan Ebberts at motionscript.com)

$
0
0

Hello Adobe comunity. I am struggling with an AE expression that I just don't know what to do! I use AE all the time at work but I am just now getting into using expressions. I picked up this Inertial Bounce online and it is working great on all my images (AI layers) with the exception of one. Ugh. I have tried deleting the layers and re importing, rendering the layer as a .png and applying the expressions, and restarting the program. I'm not sure what is going on here?

 

My process:

 

Import AI file as a comp/Document Size

 

Open comp/ select layer and create keyframes at 0;00;00;00 and 0;00;00;05

 

go to keyframe at 0;00;00;00 and set Scale to 0% and add easy ease out

 

hold down alt + left mouse click to open expression and copy and paste this code:

 

n = 0;

if (numKeys > 0){

n = nearestKey(time).index;

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

}

}

if (n == 0){

t = 0;

}else{

t = time key(

n).time;

}

if (n > 0 && t < 1){

v = velocityAtTime(key(n).time thisComp.

frameDuration/10);

amp = .05;

freq = 4.0;

decay = 8.0;

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

}else{

value;

}

 

I immediately get this error:

Screen Shot 2017-07-26 at 10.49.12 AM.pngScreen Shot 2017-07-26 at 11.03.24 AM.png

Screen Shot 2017-07-26 at 11.03.58 AM.pngScreen Shot 2017-07-26 at 11.05.08 AM.png

 

I would appreciate any help I can get on this issue!

How to smoothly interpolate between two orientation values?

$
0
0

Hi everyone, recently I've been working on interpolating two orientation values smoothly in after effects expression. And I want to use only expression, no keyframes, so it can be dynamic.

 

Here is my scenario. I have two cameras that are in different position and rotation status and I want to morph between them on the third camera.

1.png

The position and point of interest property, I can handle them with my expression. But the interpolating process of orientation property is going crazy.

Probmatic Orientation.gif

My expression used on orientation property is as below:

 

var C1 = thisComp.layer("Camera 1");
var C2 = thisComp.layer("Camera 2");
var C1Orient = getWorldOrient(C1);
var C2Orient = getWorldOrient(C2);
linear(time,0,10,C1Orient,C2Orient);

function getWorldOrient(L){

var u = fromWorldVec(L.toWorldVec([1,0,0]));
var v = fromWorldVec(L.toWorldVec([0,1,0]));
var w = normalize(fromWorldVec(L.toWorldVec([0,0,1])));

var sinb = clamp(w[0],-1,1);
var b = Math.asin(sinb);
var cosb = Math.cos(b);

if (Math.abs(cosb) > .0005){  var c = -Math.atan2(v[0],u[0]);  var a = -Math.atan2(w[1],w[2]);

}else{

  var a = (sinb < 0 ? -1 : 1)*Math.atan2(u[1],v[1]);  var c = 0;

}
return [radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)];
}

 

Basically, I get the world Orientation of those two cameras, then linearly interpolate between them. But it doesn't work well.

 

Then I got  another expression as between

 

var C1 = thisComp.layer("Camera 1");
var C2 = thisComp.layer("Camera 2");

var u1 = fromWorldVec(C1.toWorldVec([1,0,0]));
var u2 = fromWorldVec(C2.toWorldVec([1,0,0]));

var v1 = fromWorldVec(C1.toWorldVec([0,1,0]));
var v2 = fromWorldVec(C2.toWorldVec([0,1,0]));

var w1 = fromWorldVec(C1.toWorldVec([0,0,1]));
var w2 = fromWorldVec(C2.toWorldVec([0,0,1]));

var u = linear(time,0,10,u1,u2);
var v = linear(time,0,10,v1,v2);
var w = normalize(linear(time,0,10,w1,w2));

var sinb = clamp(w[0],-1,1);
var b = Math.asin(sinb);
var cosb = Math.cos(b);
if (Math.abs(cosb) > .0005){  var c = -Math.atan2(v[0],u[0]);  var a = -Math.atan2(w[1],w[2]);
}else{  var a = (sinb < 0 ? -1 : 1)*Math.atan2(u[1],v[1]);  var c = 0;
}

[radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)];

 

In some cases it works, but in some it doesn't. Such as below:

problem2.gif

 

Here is the project file if you want to take a look at:

https://www.sendspace.com/file/jv05o4

 

So I am wondering how I can interpolate between them. I heard about quaternion. But It seems that quaternion is not built in after effects expression. And it is way beyond my ability.

 

Anyone's help will be appreciated!

 

Thanks,

Aaron

Replace comma with dot in a text layer expression

$
0
0

Hi!

 

I need to do a simple counter from 0 to billions so i found this expression that works perfectly:

 

//begin code

 

startTime = 0; //seconds

endTime = 5; //seconds

beginCount = 0;

endCount = 9700698977;

hasCommas = true;

function addCommas ( s ){

if( s.length <= 3 )

return s;

else

return s.substring(0 , 3) + "," + addCommas(s.substring(3, s.length));

 

}

function reverse( s ){

newStr = "";

for(i = s.length-1; i >= 0; i--)

newStr += s.charAt(i)

return newStr;

}

 

val = Math.round (linear(time, startTime, endTime, beginCount, endCount) );

if( hasCommas )

reverse (addCommas(reverse( val + "" )))

else

val

 

 

//end code

 

The problem is that i need to change the commas with dots to look like 9.700.698.977, anyone know how to do it?

Fade In/Out - Audio Expression

$
0
0

I have the expression below and wanted that the transition of audio between -192 and 0, and 0 to -192 be smooth during 2 seconds.

 

intro = comp("MASTER").layer("Control").effect("Intro")("Slider"); // example: results in 20
preview = comp("MASTER").layer("Control").effect("Preview")("Slider"); // example: results in 10

if(time < intro || time > preview) [-192,-192] else [0,0]; // the duration is 10 secs at 0 dB between 20 and 30 secs

 

How can I make a fade in, and also a fade out?

Get self position in position expression

$
0
0

Hi,

 

I have a position experssion on a layer, something like this:

pos = transform.position + [10,0];

[pos[0], pos[1]]

 

And it works fine - the layer appears with constant offset by X.

But how AE handle this situation? Do it call expression again when I try to get position as 'transform.position'? Why no deadlock here?

 

Could you please explain. Many thanks!

Using Markers and Expressions to animate slider value

$
0
0

Hello,

 

I have a pie chart set up in my animation, pie chard value comes from a dynamic source. I have everything working, but I want to replace the keyframe with layer markers instead. I've applied the below expression to the slider that's controlling "Pie Segment 1". After Effects is recognising the value change at each marker, but only when I remove any 4 of the 5 ease(time... lines below.

 

So, my question is, how can I combine multiple ease(time expressions within the same layer?

 

I hope this makes sense.

Thanks in advance for any help.

 

 

startMarker = thisComp.layer("Pie Segment 1").marker.key(1).time;

midMarker = thisComp.layer("Pie Segment 1").marker.key(2).time;

hold1Marker = thisComp.layer("Pie Segment 1").marker.key(3).time;

dynamicMarker = thisComp.layer("Pie Segment 1").marker.key(4).time;

hold2Marker = thisComp.layer("Pie Segment 1").marker.key(5).time;

endMarker = thisComp.layer("Pie Segment 1").marker.key(6).time;

 

startValue = 0;

midValue = 25;

dynamicValue = thisComp.layer("Display_Ctrl").effect("Slider Control")("Slider");

endValue = 0;

 

 

ease(time, startMarker, midMarker, startValue, midValue);

ease(time, midMarker, hold1Marker, midValue, midValue);

ease(time, hold1Marker, dynamicMarker, midValue, dynamicValue);

ease(time, dynamicMarker, hold2Marker, dynamicValue, dynamicValue);

ease(time, hold2Marker, endMarker, dynamicValue, endValue);

Triggering a random color change with audio amplitude?

$
0
0

Hey guys, I have a project I'm working on where I want the audio (specifically the bass hit in the song) to trigger a color change of the background's color. I am almost getting the desired effect, but it is not an instant change, and seems to change multiple times for each bass hit rather than just once per beat. The other unintended effect is that when the bass beat stops completely, the color changes back to the original hue the layer has before the timeline starts. Instead, I'd like each hit to make the color change and it keep it there until the next beat. I would appreciate any and all help to try to get this to work!

 

First, I isolated the beat of the song and converted the audio to keyframes. I have named this keyframed slider layer "bass". Next, I am starting with a solid the size of my composition and using the Hue/Saturation effect. From there I am making it colorize the layer, writing the expression on the stopwatch of the Hue property. This is the expression I currently have:

 

threshold = 20.0; //audio amplitude to trigger color change
b = thisComp.layer("bass").effect("Both Channels")("Slider"); //bass layer
c = (b+(2*time)); //Hue change increment as to grow over time
accum = 0;

above = false;
frame = Math.round(time / thisComp.frameDuration);
while (true){
  t = frame * thisComp.frameDuration;
  if (above){
    if (b.valueAtTime(t) < threshold){
      accum += 0;
      frame++;
      break;
    }
  }else if (b.valueAtTime(t) >= threshold){
      accum += c;
      above = true;
  }
  if (frame == 0){
    break;
  }
  frame--
}
if (! above){
  t = 0;
}else{
  t = time - frame * thisComp.frameDuration;
}


effect("Hue/Saturation")("Colorize Hue") + accum

 

Any thoughts?


Why do I need an expression to Scale X/Y independently?

$
0
0

Scale is what... the 2nd or 3rd most used form of motion?

 

So why do I need an expression (and a **** tonne of googling) to find out how to link the X or Y scale of an object independently to a slider?

 

Why doesn't each of the two scales (X/Y) have the ability to simply be pickWhipped to a Slider or any other form of controller?

 

Would make sense, surely. And save newcomers a world of time.

 

UPDATE: Part 2 of this question:

 

If this works:

[temp, temp]

 

then why can't this work?

[temp, value]

 

Would this also make too much sense?


Surely it would be far more logical than this nonsense:

[temp[0], value[1]]


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)

After Effects Expressions test tool?

$
0
0

I'm a web developer, i know javascript and I need to help a person on AE expressions

he has C6 version

 

I would like to know if is available some sort of tool to test the code without AE or if is available a free limited software just for this kind of test?

 

Does Expressions language has major changes across versions?

 

Any way to output object and variables like an alert / console.log?

 

What we need to do is to open a JSON and assign values in son to AE variables

 

Thanks

Loop through a text array

$
0
0

hi!

 

I want to do a simple loop through a text array and write it out at a given interval.

 

I thought this would be a simple task but I can't get the actual loop to build on itself – instead I get the end result right away, since how AE interprets code.

 

Anyone have an easy to use solution for looping through a text array? 

About JSX importing in AfterEffects 15.1

$
0
0

I've been importing json files with stringified javascript and evaled them in my comps to reuse scripts.

Since updating to 15.1 I get an error when I try to import them and as the error tells me, I renamed them to jsx files and it works fine.

 

I would like to know the specification of the imported jsx files. (Not the extended script jsx)

Are they just basically the same as imported JSON only with different file extensions?

I was hoping if I can write javascript directly without the hassle of having to stringify it everytime.

Are there any documents related to this?

Viewing all 47983 articles
Browse latest View live


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